Login system troubles

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
NessTheHero
Forum Newbie
Posts: 3
Joined: Thu Oct 13, 2005 1:23 pm
Location: Eagleland

Login system troubles

Post 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.
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post 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.
NessTheHero
Forum Newbie
Posts: 3
Joined: Thu Oct 13, 2005 1:23 pm
Location: Eagleland

Post 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!
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

What browser are you using? Are you checking your browser's cookie settings?
NessTheHero
Forum Newbie
Posts: 3
Joined: Thu Oct 13, 2005 1:23 pm
Location: Eagleland

Post 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.
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

np ;) best of luck
Post Reply