Re: session timeout

From: Date: Thu, 13 Nov 2003 15:10:11 +0000
Subject: Re: session timeout
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-169502@lists.php.net to get a copy of this message
From: "pete M" <pmorgan@ukds.net> > How do I set the session timeout - eg someone leaves a broweser for say > half an hour then have to log in again.. > > As I'm on an intranet I want to increase ro 3 hours Exact method: Save the current time on each request in the session. On each request, check that time and if it's over 3 hours, then end the session / force them to log in again. Approx. Method: Look at the session.gc_maxlifetime setting in php.ini. This setting controlls when session files are cleaned up. If the files have not been accessed in "gc_maxlifetime" seconds when the garbage collection is initiated, then the file is deleted. Upon the next request, the session will be empty and the user should be forced to log in again. I say this is approx. because garbage collection is triggered on a random process based upon your requests. So files can run over the "gc_maxlifetime" setting sometimes if the collection isn't triggered. I just rely on this, though... it's close enough for government work. :) ---John Holmes...

« previous php.general (#169502) next »