If you try to save an object into the $_SESSION variable, you will probably notice this error: __PHP_Incomplete_Class Object
This error occurs when an object cannot be serialized and deserialized properly. For this reason, before assigning an object to a session variable, you must serialize it using the function
$_SESSION["my_var"] = serialize($my_object);
To deserialize it you just have to call the opposite function
Pay attention: the unserialize function needs to know the structure of the original object, so remember also to include the declaration of the original class. Remember to call the session_start() as first function of your PHP script.
This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.