>$customer = new Customer($_GET['facilityID'], $_GET['customerID']); >$_SESSION['acceptPayment']['serializedCustomer'] = serialize($customer); > >so now when I have moved on to another page or another instance of the >same page and I want to access the object from the session var, I do so >like this: > >$customer = >unserialize($_SESSION['acceptPayment']['serializedCustomer']); > >and now you can access the object. There is a hidden jewl about this >method, I now no longer have to include or require the class file because >it is already defined in the serialized string.
Really, you don't need the serialize/unserialize in there, as they are handled automagically. $_SESSION['customer'] = $customer; and $customer = $_SESSION['customer'] should work just fine. I'm doing this with 4.3.2, and a casual glance at my sess_* files in /tmp shows that the objects are stored in serialized form and the __sleep() method is called the usual way. My understanding is that classes must be defined prior to unserializing an object if you dan't want to risk having the object becoming disassociated from its class, but your method above does have the advantage that you decide when that serialization takes places and can load the classes there, rather than having to do so prior to session_start(). http://www.php.net/manual/en/language.oop.serialization.php --------------------------------------------------------------------- michal migurski- contact info and pgp key: sf/ca http://mike.teczno.com/contact.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php