Is there a built-in way to know if a given session variable is a serialized object? Say I retrieve a value like $_SESSION[‘foo’], but I don’t know if it was originally a string or if it is a serialized object. Is there some way to check, or once serialized does PHP just see a string as a string as a string?
Share
It’s a pretty common misconception that you have to manually serialize objects before putting them in session. That is not the case. You can simply assign an object instance to a slot in
$_SESSION, and PHP will automagically serialize and unserialize it for you, between requests.