Re: Serializing objects and storing them is sessions [fixed]

From: Date: Fri, 09 Apr 2004 18:49:28 +0000
Subject: Re: Serializing objects and storing them is sessions [fixed]
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-183024@lists.php.net to get a copy of this message
Kelly Hallman wrote:
Apr 9 at 11:12am, Jason Giangrande wrote:
You shouldn't serialize() objects prior to assign to a session variable. The default session handler automatically serializes the data. Assigning a serialized object value to a session just adds redundancy and overhead.
Actually, only if you create the session with session_register() are they serialized automatically. If you simply assign an object to the $_SESSION array it must be serialized manually.
When writing the above response, I had noted the documentation mentioned something to this effect. I believe this is incorrect or ambiguous. Try it without serializing, it works.
After retesting, it seems you are correct. I guess the same bad __sleep() code that was causing the object not to unserialize at all was also preventing automatic serialization. However; it does not seem to harm anything if serialize() and unserialize() are called manually on an object. It's just extra code that doesn't do anything, and therefore, can be removed. -- Jason Giangrande <jason@giangrande.org> http://www.giangrande.org http://www.dogsiview.com

« previous php.general (#183024) next »