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 running some tests, I can't speculate on the exact operation, as it
appears that the session handler may be 'manually' serializing any objects
before serializing the session data, as opposed to this being inherent in
the handler's serializing of the session data.

The point is, it's not necessary to manually serialize() the object.  
Regardless of the semantics, it happens transparently. Advantageous
because then you can just access the object directly via the session
variable, without needing to convert it in and out every time.

-- 
Kelly Hallman

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to