Session destroyed out of nowhere in PHP

旧街凉风 提交于 2019-12-10 14:47:31

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!