Storing Objects in Sessions

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']);