Re: Passing object reference to session

From: Date: Thu, 07 Feb 2008 08:11:11 +0000
Subject: Re: Passing object reference to session
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-268851@lists.php.net to get a copy of this message
Michael Moyle schreef:
Hi, I am new to the list and have a question that inspired me to join the list as I can not find any answer online. When a object reference is passed to the $_SESSION array what happens to
let's assume php5. all objects are reference like, they behave from a user POV as objects would in php4 if you passed them by reference explicitly. that said they're not really references - there is a Sara Golemon article which explains it ... not that I truely understand the inner machinations of the engine.
the object? Is the object serialized and saved in session (in this case file)? Or just the reference with the object in memory remaining on the heap?
php is 'share nothing' architecture ... everything disappears at the end of a request - nothing remains in memory. an object stored in $_SESSION will be automatically serialized and saved where ever the session data is saved (usually to disk). the only thing to remember is that you must have the class of the object stored in $_SESSION loaded *before* you restart the session otherwise php will generate an object of class stdClass.


« previous php.general (#268851) next »