PHP: session | Failed to decode session object

2019-07-23 15:24发布

问题:

I try to add e-commerce features into a legacy project, so I still need my old session-handler. I use PHP v7.1.14 and Session2DB (https://github.com/voku/session2db/tree/4.0.0) in this project. Now I have a strange problem with this "Legacy Project" + Symfony 3.4.4 + Sylius 1.1.0 and the session handling.

Symfony session config:

session:
    storage_id: session.storage.php_bridge
    handler_id: ~

Info: https://symfony.com/doc/3.4/session/php_bridge.html

Error: if I try to login into the admin view of Sylius, I see this error

session_start(): Failed to decode session object. Session has been destroyed

... any idea how I can debug / fix this?

EDIT: If I try to use native php session handling in the legacy project + the above Symfony config I get the following error. So I think the decode error is something in Session2DB.

Failed to unserialize the security token from the session.

... maybe any idea how I can debug / fix this?

回答1:

Im my case, the reason of error was non-encoded output of random_bytes() function stored in session variable.