Page 1 of 1

Login system troubles

Posted: Thu Oct 13, 2005 1:37 pm
by NessTheHero
Okay, here's the scoop. I've tried writing a decent login script for my webpage. I never go wrong with Session variables. I mean, they stay set for the time the browser is open and I can access all the secure pages, but what I want to do is to be able to close to browser, reopen it, and stay logged in. I tried cookies and they unset for some reason! I checked it with print_r and the cookie isn't there anymore when I reopen the browser, even though I set the expiration to a whole year! (time() + 60*60*24*365)

Is there any other way to have a solid login system that stays logged in even when the browser is closed?




Hell, I even tried using IP addresses at one point, but some people couldn't log in because their IP changed.

Any help or direction towards help or a tutorial would be great. Thanks!

E: Oh, and right now my server is on my laptop, with Apache, so my site is located at 127.0.0.1, just in case that makes a problem for cookies and I didn't know.

Posted: Thu Oct 13, 2005 1:48 pm
by chrys
Cookies stay on someone's computer until they expire, or until someone removes them. If you want to store their info in a cookie it will remain until the cookie is gone. You can set the expire time of the cookie to a year or something and it won't go away for a long time.

Posted: Thu Oct 13, 2005 2:43 pm
by NessTheHero
But thats the thing. I DID set it to a year, then when I closed the browser and reopened the page, the cookie was gone!

Posted: Thu Oct 13, 2005 2:46 pm
by chrys
What browser are you using? Are you checking your browser's cookie settings?

Posted: Thu Oct 13, 2005 2:50 pm
by NessTheHero
*sigh* Never mind. It turns out it was an error due to too few equal signs in an if-then, and I forgot to set their username to all caps for matching the cookie.

It figures that I ask for help, then fix it 30 minutes later.


Oh well. Thanks anyway chrys.

Posted: Thu Oct 13, 2005 3:00 pm
by chrys
np ;) best of luck