Stay Logged In
Just started with PHP and have written my own news system and have just finished a good login system tutorial. I was pondering what I could add on to the login system and came to the conclusion that a "stay logged in" feature would be nifty.
Is there any other way to do it other than with cookies? I tried using cookies but they seemed to be rather temperamental and liked giving 'header' errors. If i'd managed to get them to work then I was thinking of storing a unique id, their username and their password (unencrypted) in the cookie then using $_COOKIE to verify the cookie data against the data in the db (mySQL).
However, as I mentioned, I ran in the 'header' error. So to recap:
1/ Is there a way, other than using cookies, to do a 'stay logged in' feature?
1.1/ If so what, and how?
1.2/ If not then i'd appreciate some guidance on how to do it with cookies
Busy posted this at 22:09 — 19th October 2003.
He has: 6,151 posts
Joined: May 2001
you could use PHP sessions
Just a side note, keeping someone logged in isn't always a good thing, opens the site up for the kiddy scripters etc. a lot of sites are now limiting the cookie life to two hours max
Khanny posted this at 00:59 — 20th October 2003.
They have: 51 posts
Joined: Dec 2002
it's possible to use PHP session to keep someone logged in? I was under the impression they were only a temporary thing that lasted the life of the browser window
Suzanne posted this at 01:25 — 20th October 2003.
She has: 5,507 posts
Joined: Feb 2000
Staying logged in isn't really staying logged in. It's an illusion using cookies. When they leave, kill the session. When they return, check the cookie and start a new session.
Alternatively, store the session in the cookie and put the session to sleep and reactivate it when they return.
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.