Jump to content

How I solved "Failed to start the session" in PS 8.2


musicmaster

Recommended Posts

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.

 

session2.thumb.jpg.81824ac477bd9639c2640702c94b2737.jpg

Edited by musicmaster (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...