Page 1 of 1

Ending sessions when the browser is closed

Posted: Thu Jun 19, 2003 6:05 pm
by pistolfire99
[Admin Edit: Moved from modcp.php?t=9726]

SBukoski:- Hey can you provide some kind of sample code. I am also in the same boat as the user who posted this message. How can I delete or force session to revalidate when a user doesnt log out, but closes the browser.
Another question I have is, how can I force the session to expire after certain time of inactivity, for ex:- something similar to yahoo mail or hotmail. If a user logs in, but is inactive for certain amount of time, and after that time, when the user clicks on one of the links, he has to login to the site, since his session has expired. Thank you for any help or sample code. Thank You

Posted: Thu Jun 19, 2003 6:16 pm
by nielsene
In this thread I show some sample code for using a cookie authenticator to protect a session. It includes the auto-expire requirements without requiring either PHP's sessions garbage collection or tracking of old sessions in a database. The script (the second version, linked near the end) probably needs some tweaking to work for you, but it should give you a decent starting point.

Posted: Fri Jun 20, 2003 3:02 am
by twigletmac
Please don't hijack other user's posts, I realise that if your question is similar it seems common sense to ask your question in the same thread but this can be confusing both for the original poster and for those trying to help when there are two conversations running in conjunction.

Mac