Forum Moderators: coopster
This is the way most of the scripts I've seen work.
Now I'm learning about session variables - and I'm wondering whether it's really necessary to register my user sessions in a MySql table - why not just use session variables to carry their id from page to page and "recognize" them as a logged in user?
I have a login form. When the user enters their id/password, I check them with the table of users, and, if they're in there, I set a $_SESSION['user'] variable.
Then, when the user goes to a new page, all I have to do is check to see if isset($_SESSION['user'])?
That sounds almost toooo simple! I must be missing something?
I have this working on my little site, which is already an accomplishment, as far as I'm concerned anyway :)
I thought that in order for the session variables to be "remembered", I had to do a session_start() on every page. But I just noticed that if I click on one of the .htm pages on my site, which of course doesn't have session_start(), I'm still "recognized" when I go back to a .php page -?
Also, what's the lifespan of a session variable? Is it finite? If not, I guess that the session would remain "open" ... as long as the browser is left open, right?
Is there no need to "manually" close sessions at all when you use session variables?