Read the session data from session storage file

前端 未结 6 1617
执念已碎
执念已碎 2020-12-01 16:20

Facing problem with PHP unserialize() function as titled it is throwing error.

unserialize() [function.unserialize]: Error at offset 0 of 1781 b         


        
6条回答
  •  被撕碎了的回忆
    2020-12-01 17:02

    That is not legal PHP serialized data, that's PHP session data.

    PHP session data uses the serialized format internally, but it is not serialized data itself.

    The only thing that can safely and sanely read session data is PHP's session code. It is sometimes possible to read it using a regular expression and some creative editing, but you can not rely upon those methods.

    If you need data out of a user's session, your best bet is to write a custom session wrapper and let it do the work when the data itself changes rather than try and work with the data after the fact.

    (I'm not talking about custom session-writing code, I'm talking about a class that you would use instead of using $_SESSION directly.)

提交回复
热议问题