Tuesday, December 20, 2011

Expire a session after certain amount of time of user inactivity in PHP?

I would like a script or a way for the user session to expire if the user has remained inactive for a certain amount of time, where the time will reset to limit should the user more. If possible, also tells the user ahead of time when the session is about to expire.





How do you do this?|||Sessions do expire through inactivity after (by default) 24 minutes. You can change the gc_maxlifetime setting in php.ini or by using the ini_set function. Whenever a page is loaded that contains the session_start() function the session timeout resets.





I guess you could have some javascript on your page that does a countdown from 24 minutes (or whatever your session expiry is set to) and then notifies the user.

No comments:

Post a Comment