|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2017-12-05 08:38 UTC] damyon at moodle dot com
Description: ------------ When unit testing session-related code in a CLI environment, appropriate PHP ini settings combined with passing false to session_cache_limiter should allow the session handler to be changed even if output has been already sent. With PHP 7.2.0RC5 calling session_set_save_handler prints warning messages, regardless of php ini settings. Very similar previously fixed bug: https://bugs.php.net/bug.php?id=55267 Very similar (but not the same) bugs with php 7.2 https://bugs.php.net/bug.php?id=74936 https://bugs.php.net/bug.php?id=74514 Test script: --------------- <?php S> ini_set('session.use_cookies', false); ini_set('session.use_only_cookies', false); ini_set('session.use_trans_id', 1); ini_set('session.cache_limiter', false); session_cache_limiter(false); echo '.'; class MySessionHandler extends SessionHandler { S> } $handler = new MySessionHandler(); session_set_save_handler($handler, true); Expected result: ---------------- One single dot of output Actual result: -------------- .PHP Warning: session_set_save_handler(): Cannot change save handler when headers already sent in [filepath]/test.php on line 17 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 19:00:01 2025 UTC |
You cannot change anything for session, once you have started output. echo ".\n"; $success = session_set_save_handler(new MySessionHandler(), true); echo ($success ? 'set' : 'fail') . "\n"; echo should print 'fail', but it's not. This must be bug. I'll look into this. If you want to start output before session initialization, use ob_start() prevent PHP from start sending output.