From: Operating system: Linux PHP version: 5.3.6 Package: Session related Bug Type: Bug Bug description:session_regenerate_id fails after header sent even if ini.use_cookies = 0
Description: ------------ When unit testing session-related code in a CLI environment, appropriate PHP ini settings combined with passing false to session_cache_limiter can allow sessions to be started even if output has been already sent. Unfortunately, session_regenerate_id() fails unconditionally even when no cookie headers would have been sent: // session.c, session_regenerate_id if (SG(headers_sent)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Cannot regenerate session id - headers already sent"); RETURN_FALSE; } // session.c, php_session_reset_id if (PS(use_cookies) && PS(send_cookie)) { php_session_send_cookie(TSRMLS_C); PS(send_cookie) = 0; } Is this just an oversight? Or intentional? Test script: --------------- <?php ini_set( 'session.use_cookies', 0 ); ini_set( 'session.use_only_cookies', 0 ); ini_set( 'session.use_trans_id', 1 ); // Don't send headers! session_cache_limiter( false ); echo 'test'; // Succeeds session_start(); // Fails session_regenerate_id(); ?> Expected result: ---------------- No warnings or errors. Output: test Actual result: -------------- testPHP Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /home/jesse.hallam/tmp/session_test.php on line 15 PHP Stack trace: PHP 1. {main}() /home/jesse.hallam/tmp/session_test.php:0 PHP 2. session_regenerate_id() /home/jesse.hallam/tmp/session_test.php:15 -- Edit bug report at https://bugs.php.net/bug.php?id=55267&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=55267&r=trysnapshot54 Try a snapshot (PHP 5.3): https://bugs.php.net/fix.php?id=55267&r=trysnapshot53 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=55267&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=55267&r=fixed Fixed in SVN and need be documented: https://bugs.php.net/fix.php?id=55267&r=needdocs Fixed in release: https://bugs.php.net/fix.php?id=55267&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=55267&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=55267&r=needscript Try newer version: https://bugs.php.net/fix.php?id=55267&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=55267&r=support Expected behavior: https://bugs.php.net/fix.php?id=55267&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=55267&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=55267&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=55267&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=55267&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=55267&r=dst IIS Stability: https://bugs.php.net/fix.php?id=55267&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=55267&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=55267&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=55267&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=55267&r=mysqlcfg