note 90351 added to book.session

From: Date: Fri, 17 Apr 2009 12:02:31 +0000
Subject: note 90351 added to book.session
Groups: php.notes 
Request: Send a blank email to php-notes+get-153426@lists.php.net to get a copy of this message
There is a nuance we found with session timing out although the user is still active in the session. The problem has to do with never modifying the session variable. The GC will clear the session data files based on their last modification time. Thus if you never modify the session, you simply read from it, then the GC will eventually clean up. To prevent this you need to ensure that your session is modified within the GC delete time. You can accomplish this like below. if( !isset($_SESSION['last_access']) || (time() - $_SESSION['last_access']) > 60 ) $_SESSION['last_access'] = time(); This will update the session every 60s to ensure that the modification date is altered. ---- Server IP: 212.124.37.9 Probable Submitter: 195.140.184.10 ---- Manual Page -- http://www.php.net/manual/en/book.session.php Edit -- https://master.php.net/note/edit/90351 Del: integrated -- https://master.php.net/note/delete/90351/integrated Del: useless -- https://master.php.net/note/delete/90351/useless Del: bad code -- https://master.php.net/note/delete/90351/bad+code Del: spam -- https://master.php.net/note/delete/90351/spam Del: non-english -- https://master.php.net/note/delete/90351/non-english Del: in docs -- https://master.php.net/note/delete/90351/in+docs Del: other reasons-- https://master.php.net/note/delete/90351 Reject -- https://master.php.net/note/reject/90351 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#153426) next »