NYCPHP Meetup

NYPHP.org

[nycphp-talk] More Objects in Sessions

Scott Mattocks crisscott at netzero.com
Fri Sep 26 10:58:38 EDT 2003


Hello,
Ok, so I have these objects that have other objects as attributes.  I 
can't get the second object to come out of the session properly.  I have 
tried using __sleep and __wakeup to serialize/unserialize but the object 
loses its methods and is pretty much useless.  I have a class method 
that can recreate the second object but it won't recreate it properly if 
called within the class itself.  ex:
// In the class definition
function __wakeup () {
	unset($this->secondObj);
	$this->createSecondObj();
	return array();
}  // This does not work!?

// In my script that uses object
$obj =& $_SESSION['obj'];
unset($obj->secondObj);
$obj->createSecondObj();  // Works fine but I don't like it!

Any ideas how to fix this?
Thanks,
Scott Mattocks




More information about the talk mailing list