Re: Serializing objects and storing them is sessions

From: Date: Fri, 09 Apr 2004 05:08:41 +0000
Subject: Re: Serializing objects and storing them is sessions
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-182952@lists.php.net to get a copy of this message
electroteque wrote:
May i ask what the advantage of storing objects in session is ? Does it cause overhead ? Like should i store the most common classes like the db and auth class in a session ?
No. A good time for storing an _object_ in the session is when the object contains mostly data. Restoring the object on the next page recreates that data. There's no benefit if the object is just full of methods, as you have to include the class before hand, anyhow. It's no different than just making a new "db" or "auth" class when the page loads. Even if the object is stored in the session, you have to include the class code before hand so PHP knows how to load the object. Does that make sense? -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#182952) next »