You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
session_write_close() returns true when the session data could not be written #24561
session_write_close() returns true even when the session data could not be written. The manual says it "Returns true on success or false on failure", but php_session_flush() returns true whenever the session was active, and php_session_save_current_state() does not report the write result.
write() called, returning false
Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: , handler: H::write) in ... on line 17
bool(true)
But I expected this output instead:
write() called, returning false
Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: , handler: H::write) in ... on line 17
bool(false)
The same happens when encoding fails (e.g. a key containing |): the recently added ext/session/tests/session_write_close_encode_failure.phpt expects bool(true) after the "Failed to write session data" warning, so I'm not sure whether returning true here is intended (meaning "the session was closed") or whether session_write_close() should report the failed write. If it should, I'm happy to send a PR for master (php_session_save_current_state() returning its result and php_session_flush() passing it on), since it changes the return value.
PHP Version
PHP 8.4.28-dev (PHP-8.4 at b4ca62e); same code on master
Operating System
Linux x86-64
This issue was found by an LLM-Enhanced Static Analysis Engine and verified manually.
Activity
jordikroon commentedon Oct 22, 2026
This behaviour is intended, and documented .See the Return Values section.
Marti2203 commentedon Oct 22, 2026
Thanks, you're right — I missed that note in the manual. Closing.