Re: object persistence within a session

From: Date: Sat, 08 Nov 2008 03:48:17 +0000
Subject: Re: object persistence within a session
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-283092@lists.php.net to get a copy of this message
On Fri, Nov 7, 2008 at 3:54 PM, Stan <stanleytberry@gmail.com> wrote: > Andrew, > Do I feel stupid! > Thanks. Welcome to the list. No need to feel stupid, and you're welcome. We were all here at some point. Even tedd, who has been programming since Rocks apparently. :-) At least you read up on the language and took a stab at a solution before you came looking for help. That's a lot more than can be said for some of the requests that show up on this list. Just something to keep in mind based on your description of the project. (You said you were trying to avoid repeated database calls on each request.) PHP sessions are usually stored in the file system (unlike ASP sessions that are stored in memory). Therefore there will be some overhead with sessions as well. (The server has to read the cookie, find the corresponding file, compare the modified time of the file to make sure the session hasn't expired, read the file into memory, and unserialize the data into variables.) You may want to experiment from project to project while you're getting used to the language until find the right balance of how much you store in sessions versus how often you repeat trips to the database. I usually use the database to store session information so that it is available regardless of which server handles a request in a clustered environment. I've found that I don't mind a few well organized database calls per page for the information I need. I know some people on this list have forgone sessions altogether in favor of other approaches. Andrew

« previous php.general (#283092) next »