Re: Re: Bug inside PHP CLI sessions

From: Date: Wed, 17 Dec 2025 17:37:16 +0000
Subject: Re: Re: Bug inside PHP CLI sessions
References: 1  Groups: php.internals php.internals 
Request: Send a blank email to internals+get-129636@lists.php.net to get a copy of this message
On 2025-12-18 06:12, Gregory Magarshak wrote:
My apologies. I made a mistake in the minimal examples to reproduce: 1. session_id($id); session_start(); echo session_id(); // empty! 2. session_id($id); echo "b"; session_start(); echo session_id(); // FINE!! 3. echo "a"; session_id($id); echo "b"; session_start(); echo session_id(); // empty again! Sincerely, Greg Magarshak <http://qbix.com/invest>
I tried your minimal reproductions in the CLI and got undefined variable warnings from the $id value. Putting in a literal session id value I get 1. session_id('session17'); session_start(); echo session_id();"
session17
2. session_id('session17'); echo 'b'; session_start(); echo session_id();
bSession cannot be started after headers have already been sent (sent from Command line code on line 1) in Command line code on line 1
3. echo 'a'; session_id('session17'); echo 'b'; session_start(); echo session_id();
aSession ID cannot be changed after headers have already been sent bSession cannot be started after headers have already been sent
I get the same results using php -r, php -a, and putting those lines in files and running them. What else is your framework doing that is being left out of this setup?

« previous php.internals (#129636) next »