Re: RE: Ending a session with a timeout

From: Date: Sat, 14 Sep 2002 07:21:23 +0000
Subject: Re: RE: Ending a session with a timeout
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-116359@lists.php.net to get a copy of this message
Hi, Saturday, September 14, 2002, 12:58:04 PM, you wrote: YN> I am developing an application where the user must login to see certain YN> pages. This is done via sessions YN> (pretty routine). YN> Question: YN> How do I expire the session if there is an inactivity time (say 10 minutes). YN> which will make the user to login again. YN> TIA YN> nyon You can set the session.gc_maxlifetime to 600 in php.ini or use the ini_set('session.gc_maxlifetime','600) at the top of your php page and as a backup store your own session check in the session itself like session_start(); $now = time(); if(!empty($_SESSION['timeout'])){ if(($now - $_SESSION['timeout']) > 600){ //destroy session stuff unset($_SESSION); } } $_SESSION['timeout'] = $now; I actually use my own session handlers and do the timeout check there. -- regards, Tom

« previous php.general (#116359) next »