Storing Objects in Sessions
- you must load the class definition files prior to calling session_start()
- I couldn't find documentation of this anywhere, but it seems that you can't name your session variable the same as the variable of the object, or PHP will remove this from the session when you call unserialize($_SESSION['varname'])
Example
// create the object $objVar = new SomeObj(); // serialize and store the object in the session $_SESSION['serObjVar'] = serialize($objVar); ... // load the Class definition file require "SomeObj.php"; // begin the session session_start(); // unserialize the object into a usable variable $objVar = unserialize($_SESSION['serObjVar']);