Skip to content
Snippets Groups Projects
Unverified Commit b278b2b4 authored by Jaime Pérez Crespo's avatar Jaime Pérez Crespo
Browse files

Fix header warnings from log flushing

This resolves #1176
parent 3fa2c2d7
No related branches found
No related tags found
No related merge requests found
...@@ -189,6 +189,11 @@ class SessionHandlerPHP extends SessionHandler ...@@ -189,6 +189,11 @@ class SessionHandlerPHP extends SessionHandler
return null; // there's no session cookie, can't return ID return null; // there's no session cookie, can't return ID
} }
if (version_compare(PHP_VERSION, '7.2', 'ge') && headers_sent()) {
// latest versions of PHP don't allow loading a session when output sent, get the ID from the cookie
return $_COOKIE[$this->cookie_name];
}
// do not rely on session_id() as it can return the ID of a previous session. Get it from the cookie instead. // do not rely on session_id() as it can return the ID of a previous session. Get it from the cookie instead.
session_id($_COOKIE[$this->cookie_name]); session_id($_COOKIE[$this->cookie_name]);
...@@ -241,7 +246,7 @@ class SessionHandlerPHP extends SessionHandler ...@@ -241,7 +246,7 @@ class SessionHandlerPHP extends SessionHandler
assert(is_string($sessionId) || $sessionId === null); assert(is_string($sessionId) || $sessionId === null);
if ($sessionId !== null) { if ($sessionId !== null) {
if (session_id() === '') { if (session_id() === '' && !(version_compare(PHP_VERSION, '7.2', 'ge') && headers_sent())) {
// session not initiated with getCookieSessionId(), start session without setting cookie // session not initiated with getCookieSessionId(), start session without setting cookie
$ret = ini_set('session.use_cookies', '0'); $ret = ini_set('session.use_cookies', '0');
if ($ret === false) { if ($ret === false) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment