问题
I am experiencing issue with a session being destroyed out of nowhere:
session_start(): Failed to decode session object. Session has been destroyed
.
Kind of impossible to replicate the issue since I got this thrown in my server log.
Any ideas what could be the roots of that problem and/or where to start because I am getting that very rare (almost never).
回答1:
This happened to me when I was storing too much in $_SESSION where they were saved using serialize() in a table. Solution: don't store too much.
回答2:
I had this problem as well and I discovered the problem was when someone posted an emoji. My current server set up couldn't handle these four bytes symbols, resulting "Failed to decode session object. Session has been destroyed".
What I did was to update to character set utf8mb4
with the collation utf8mb4_unicode_ci
.
In order for this to work you need to make this change to your database, the database tables and the table columns. Also, in your application code, set the connection character set to utf8mb4
.
This guide might help >
来源:https://stackoverflow.com/questions/34944892/session-destroyed-out-of-nowhere-in-php