tmyonline Posted March 5, 2008 Share Posted March 5, 2008 Guys: Suppose I need to log out a user session after, say, 30 minutes of inactivity. Is there something that can monitor user's inactivity or do I have to user Javascript for this ? Thanks. Link to comment https://forums.phpfreaks.com/topic/94505-log-out-a-user-session/ Share on other sites More sharing options...
deansatch Posted March 5, 2008 Share Posted March 5, 2008 you can use a cookie Link to comment https://forums.phpfreaks.com/topic/94505-log-out-a-user-session/#findComment-483943 Share on other sites More sharing options...
uniflare Posted March 5, 2008 Share Posted March 5, 2008 javascript... just, no. sessions have time limits im sure of it, if you mean user session by "cookie and mysql tables", then add in the sql table "last_moved", then whenever the user loads/reads/edits a page then put the current unix timestamp into that field. then just check the field + 30 minutes is less than or equal to the current time; if it is then log the user out (remove cookies or w/e). hope this helps, Link to comment https://forums.phpfreaks.com/topic/94505-log-out-a-user-session/#findComment-483946 Share on other sites More sharing options...
revraz Posted March 5, 2008 Share Posted March 5, 2008 By default, the PHP.INI is set to 24 mins (1440 seconds). If you want to change it to 30, just add to it. Link to comment https://forums.phpfreaks.com/topic/94505-log-out-a-user-session/#findComment-483947 Share on other sites More sharing options...
discomatt Posted March 5, 2008 Share Posted March 5, 2008 Yes, session automatically expire after a certain amout on inactivity... you have to change session.gc_maxlifetime in php.ini, or use ini_set() Link to comment https://forums.phpfreaks.com/topic/94505-log-out-a-user-session/#findComment-483949 Share on other sites More sharing options...
PFMaBiSmAd Posted March 5, 2008 Share Posted March 5, 2008 Session garbage collection is not meant to end sessions. It is solely for the purpose of deleting session data files that have not been recently accessed. Using GC for any other purpose will cripple the session functionality for any thing else you want to use it for on your site. Garbage collection is only checked on session_start() and it runs randomly based on the session.gc_probability and session.gc_divisor settings. To automatically log anyone out, you must store their last time of activity and then check on each new activity if the last time is farther in the past then allowed. Link to comment https://forums.phpfreaks.com/topic/94505-log-out-a-user-session/#findComment-483994 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.