|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-11-29 22:55 UTC] sniper@php.net
[2005-11-30 20:22 UTC] kenashkov at gmail dot com
[2018-04-17 07:53 UTC] robert dot schneider at colop dot co dot at
[2018-04-17 10:13 UTC] requinix@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 07:00:01 2025 UTC |
Description: ------------ Let suppose that we use the session_set_save_handler to register own session handling functions and we have an expired session (but not cleaned by the garbage collector yet). When we start the session with session_start() we get the following sequence of calling the registered functions: open read gc write close I think the garbage collector (gc) should be called BEFORE the read function (in order to clean that expired session beofre it is read). In the way it is, is possible for the web site visitor to use an old session (only once of course, because immediately after read is called gc and for the second visit the session will be already deleted). Maybe the same problem exists when is not used the session_set_save_handler, but with it the sequence can be seen. Reproduce code: --------------- <? function open() { print 'open<br>'.PHP_EOL; return true; } function close() { print 'close<br>'.PHP_EOL; return true; } function read() { print 'read<br>'.PHP_EOL; return ''; } function write() { print 'write<br>'.PHP_EOL; return true; } function destroy() { print 'destroy<br>'.PHP_EOL; return true; } function gc() { print 'gc<br>'.PHP_EOL; return true; } ini_set('session.gc_probability',1); ini_set('session.gc_divisor',1); session_set_save_handler('open','close','read','write','destroy','gc'); session_start(); session_write_close(); ?> Expected result: ---------------- open gc read write close Actual result: -------------- open read gc write close