PHP Session Timeout / Auto Logout

PHTech

Senior Member
Joined
Aug 21, 2006
Messages
588
Reaction score
0
Location
Witbank
Hi there...

Any tips and / or easy ways to create an automatic logout in PHP / Dreamweaver. For instance: if there is no activity in 200 seconds, then it must logout the user.

AND

How do I change the login text to logout only after a user have logged in?
 
Thanx for the good link... Found some useful stuff on there, but still nothing on closing a session after a certain amount of time...
 
Been yonks since I coded in PHP.
Might be something in the php.ini?
 
Have you tried cookies? Simply set a cookie that is valid for 200seconds. Every time the person goes to another page, the cookie resets to 200seconds until expiry.
 
Hi there...

Any tips and / or easy ways to create an automatic logout in PHP / Dreamweaver. For instance: if there is no activity in 200 seconds, then it must logout the user.

AND

How do I change the login text to logout only after a user have logged in?

There is a session autoexpire setting in the php.ini but there are a few caveats to consider.

Depending on your application you may consider augmenting standard php sessions with a database-backed solution.
 
There is a session autoexpire setting in the php.ini but there are a few caveats to consider.

Depending on your application you may consider augmenting standard php sessions with a database-backed solution.

w00t! Alzheimer's is being kept at bay!
 
if($currClickTime - $lastClickTime > 200) $_SESSION = array();
 
Or have a field in a database table for "last activity time" and for each action requiring authentication, check it against the current time
 
Top
Sign up to the MyBroadband newsletter
X