Checking serial objects
Is there a built-in way to find out if a given session variable is a serialized object? Let's say I get 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 a way to check, or once serialized, PHP just sees the string as a string as a string?
+1
source to share
3 answers
It is a fairly common misconception that you must manually serialize objects before injecting them into a session. This is beside the point. You can simply assign an instance of an object to a slot in $_SESSION
, and PHP will automatically serialize and unserialize it for you between requests.
+3
source to share