No, the object is still unserialized when the session is started.
One way to get around it is by forcing string unserialization by doing
something like:

$obj = new obj;
$_SESSION['obj'] = 'a not so random string'.serialize($obj);

... then to load ...
$ser = unserialize(str_replace('a not so random string', '',
$_SESSION['obj']));

The logic can be moved into an extended Zend_Session_Namespace class so that
you can do:

$sess = new My_Session_Namespace();
$sess->obj = $obj;
var_dump($sess->obj);

The gotcha here is that you're no longer working with an object reference,
and each subsequent '__get' becomes a new instance. 
$obj1 = $sess->obj;
$obj2 = $sess->obj;
var_dump($obj1 !== $obj2); 

You also need to write the object back into the session after modifications.

A better solution would probably be to perform manual serialization on
__destroy and then do on-the-fly unserialization on access (and replace the
value with the unserialized counterpart. 
Haven't tried that out though.

David

-- 
View this message in context: 
http://zend-framework-community.634137.n4.nabble.com/problem-with-autoloading-class-definition-for-serialization-and-deserialization-tp3062477p3064758.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to