#20650 [NEW]: Change of Read($sess_id) to ($sess_id, $maxlifetime)

From: Date: Tue, 26 Nov 2002 15:43:47 +0000
Subject: #20650 [NEW]: Change of Read($sess_id) to ($sess_id, $maxlifetime)
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-25860@lists.php.net to get a copy of this message
From: andreas.birrer@ag.ch Operating system: PHP version: 4.2.2 PHP Bug Type: Feature/Change Request Bug description: Change of Read($sess_id) to ($sess_id, $maxlifetime) If I install a user save handler class e.g. MySqlSessionHandler with methods Read, Write, GC etc. MySqlSessionHandler::Read($sess_id) is always called before MySqlSessionHandler::GC($maxlifetime) This has the problem, that a session is read, which potentially would be garbage collected. Therefore it would be nice to get the $maxlifetime parameter also in Read e.g. Read($sess_id, $maxlifetime) This allows to return an empty session if it has timeouted. For Clarification here are two Methods GC and Read with $lifetime information function Read($sess_id, $maxlifetime) { // beware of timouted sessions not yet gced $time_stamp= time(); $removeDate= date("YmdHis", ($time_stamp - $maxlifetime)); $search_query= "SELECT * FROM $_session_table WHERE (session_id = '$sess_id') and (last_accessed >= $removeDate)"; $result= @ mysql_query($search_query, $_connection); if(!$result) { // No session found - return an empty string return ""; } else { // Found a session - return the serialized string $row = mysql_fetch_array($result); return $row["session_variable"]; } } function GC($max_lifetime) { global $_connection; global $_session_table; $time_stamp= time(); $removeDate= date("YmdHis", ($time_stamp - $max_lifetime)); $delete_query = "DELETE FROM $_session_table WHERE last_accessed < $removeDate"; $result = @mysql_query($delete_query,$_connection); return true; } -- Edit bug report at http://bugs.php.net/?id=20650&edit=1 -- Try a CVS snapshot: http://bugs.php.net/fix.php?id=20650&r=trysnapshot Fixed in CVS: http://bugs.php.net/fix.php?id=20650&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=20650&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=20650&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=20650&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=20650&r=support Expected behavior: http://bugs.php.net/fix.php?id=20650&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=20650&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=20650&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=20650&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=20650&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=20650&r=dst IIS Stability: http://bugs.php.net/fix.php?id=20650&r=isapi

« previous php.bugs (#25860) next »