• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

Location of login using OO PHP

Hi All,
This is probably a pretty simple question but I'm just wondering about structure of a php script.  I'm writing a user login system using object oriented php.  I've seen a couple of examples online where they have a simple system for users to login.  My question is that some of the examples have the login section in a user class while some have it in a session class.  Which one would be preferrable?  I'd also like to have a guest access as well.  My session information is stored in a MySQL database.  Like I said the whole thing is pretty simple so I don't think I need any ready built code, plus I'd like to learn the stuff myself.  Thanks in advance.
P.S. I didn't include any code since this is more of an organizational question, but if anyone wants to see what I'm going off of just let me know and I'll copy it in.
0
William-B
Asked:
William-B
  • 2
  • 2
2 Solutions
 
Dave BaldwinFixer of ProblemsCommented:
It doesn't matter all that much where the login page is.  It is more important to realize the code that checks the login has to run on every page that is supposed to be protected by the login.  You would want to make that part pretty simple and direct so it is essentially invisible to the rest of the page.
0
 
Ray PaseurCommented:
0
 
William-BAuthor Commented:
Thanks for your responses.  I guess I may not be understanding the answers you gave.  I was wondering which class should handle the login procedure, the Session class or the user class.  I might just be having an obtuse day, so please let me know if that's the case.  Thanks again.
0
 
Dave BaldwinFixer of ProblemsCommented:
We're not exactly answering your question because where you put the login isn't that important.  What is really important is checking the login status on every page that is 'protected' by the login.  That code needs to be at the beginning of every single page that is to be protected.
0
 
William-BAuthor Commented:
Thanks for your help guys.  Points all around.
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now