Suddenly I had in my PS 8.2 a "Failed to start the session" error that blocked me from entering my backoffice. I tried emptying the cache and deleting the browser cookies but without effect.
What finally helped was forcing Prestashop to create a new session key.
The error happened on line 193 of /vendor/symfony/symfony/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php
This was the relevant code:
if ($sessionId && $this->saveHandler instanceof AbstractProxy && 'files' === $this->saveHandler->getSaveHandlerName() && !preg_match('/^[a-zA-Z0-9,-]{22,250}$/', $sessionId)) {
// the session ID in the header is invalid, create a new one
session_id(session_create_id());
}
// ok to try and start the session
if (!session_start()) {
throw new \RuntimeException('Failed to start the session.');
}
What helped was changing it to:
if ($sessionId && $this->saveHandler instanceof AbstractProxy && 'files' === $this->saveHandler->getSaveHandlerName() && !preg_match('/^[a-zA-Z0-9,-]{22,250}$/', $sessionId)) {
// the session ID in the header is invalid, create a new one
session_id(session_create_id());
}
session_id(session_create_id()); /* ADDED CODE */
// ok to try and start the session
if (!session_start()) {
throw new \RuntimeException('Failed to start the session.');
}
Of course after I had successfully logged in into the backoffice I undid this change.