tmyonline Posted March 26, 2008 Share Posted March 26, 2008 Hi guys, I tried to log out a user after 15 minutes of inactivity. I did set the session.gc_maxlifetime = 900 (~ 15 minutes) in the php.ini file but it did not work. What can be an alternative approach ? Thanks. Link to comment https://forums.phpfreaks.com/topic/97967-logging-out-a-user-after-15-minutes-of-inactivity/ Share on other sites More sharing options...
revraz Posted March 26, 2008 Share Posted March 26, 2008 That's just the Garbage Collector cleanup setting. Link to comment https://forums.phpfreaks.com/topic/97967-logging-out-a-user-after-15-minutes-of-inactivity/#findComment-501244 Share on other sites More sharing options...
trq Posted March 26, 2008 Share Posted March 26, 2008 You want to set session.cookie_lifetime. Link to comment https://forums.phpfreaks.com/topic/97967-logging-out-a-user-after-15-minutes-of-inactivity/#findComment-501248 Share on other sites More sharing options...
tmyonline Posted March 26, 2008 Author Share Posted March 26, 2008 Unfortunately, I tried setting: session.cookie_lifetime = 60 (~ 1 minute) but it did not work even after 2-3 minutes of inactivity. Revraz, where can I find the Garbage Collector and what am I supposed to do with it to log out a user after 15 minutes of inactivity ? Thanks. Link to comment https://forums.phpfreaks.com/topic/97967-logging-out-a-user-after-15-minutes-of-inactivity/#findComment-501274 Share on other sites More sharing options...
cooldude832 Posted March 26, 2008 Share Posted March 26, 2008 garbage collector only eats dead sessions, not live ones it runs every 15 minutes in terms of "server" time i.e 1:00 am 1:15 am 1:30 am 1:45 am etc. You want to have a session made at 1:04 AM become expired when the user doesn't navigate for 15 minutes so i.e 1:19 am this is done with setting the life of an individual cookie or session not the garbage collectors frequency Link to comment https://forums.phpfreaks.com/topic/97967-logging-out-a-user-after-15-minutes-of-inactivity/#findComment-501284 Share on other sites More sharing options...
tmyonline Posted March 26, 2008 Author Share Posted March 26, 2008 ok, I can create a session once a user logged in. However, how do I track the inactivity of the user over 15 minutes ? Link to comment https://forums.phpfreaks.com/topic/97967-logging-out-a-user-after-15-minutes-of-inactivity/#findComment-501319 Share on other sites More sharing options...
doni49 Posted March 29, 2008 Share Posted March 29, 2008 When the page loads, create a session variable equal to the current time. On future loads of this page, check to see if this variable has been set and if it has compare it to the current time. If more than 15 minutes have passed, log them out. You could even force the page to reload after a set amount of time which would cause this to take effect even if the user was away from the PC when it was time. If doing this, I'd probably force the reload after 18 minutes or so to ensure that 15 minutes have actually passed. Link to comment https://forums.phpfreaks.com/topic/97967-logging-out-a-user-after-15-minutes-of-inactivity/#findComment-503778 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.