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. Quote Link to comment Share on other sites More sharing options...
deansatch Posted March 5, 2008 Share Posted March 5, 2008 you can use a cookie Quote Link to comment 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, Quote Link to comment 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. Quote Link to comment 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() Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.