|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-12-29 17:45 UTC] jani@php.net
-Package: Feature/Change Request
+Package: Session related
[2012-03-31 04:10 UTC] yohgaki@php.net
[2012-03-31 04:10 UTC] yohgaki@php.net
-Status: Open
+Status: Wont fix
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 12:00:01 2025 UTC |
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; }