Re: what vars should go in session vars?
| From: | Conor McTernan | Date: | Wed, 23 Jan 2002 18:41:43 +0000 |
| Subject: | Re: what vars should go in session vars? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-81734@lists.php.net to get a copy of this message | ||
I'm working on a web app myself, in my spare time, and I came across the
same questions as yourself a while ago. In the end, I decided to design my
app so that I have User objects, which I can then store as session
variables, meaning I can store the user Name, ID, preferences, etc, and
then pass it from page to page.
I'm still implentating most of my code, so I'm afraid I cant tgive much
feedback on performance issues on it, but I find it to be nice solution to
the problem. That said, I'll prob be posting here in about 3 weeks
complaining that none of my code works or something.
Good luck with you app anyway, whatever approach you decide on..
Conor
On Wed, Jan 23, 2002 at 01:29:46PM -0500, Erik Price wrote:
> Hello, I have a question about everyone's opinion on the topic of
> sessions:
>
> I am running the whole linux/mysql/php/apache thing and I love it. If I
> haven't mentioned it before, I'm teaching myself how to do all this with
> a web-based app (site) that combines a great deal of functionality, such
> as searching a database of images, requesting projects from my
> department, checking the status of those projects, and message boards
> (where the topic is a certain project -- each project has a message
> board). Blah blah blah.
>
> What I'm wondering is, what should I store in session variables?
> Originally, I was thinking that after login/authentication, only the
> userID number should be stored in the session, because this number can
> easily be used to consult MySQL and get any other information necessary
> for the user, to influence the way the site behaves. But I was thinking
> of adding ten pre-set style sheets (diff't colors, fonts, etc), and the
> user can choose one of them and store it in "users.stylesheet" or
> whatever. (A neat idea if I do say so myself.)
>
> But would this would mean yet ANOTHER query to the database for every
> single page in the site, as the userID is checked to find the user's
> stylesheet, which then causes the page to perform an include() on that
> particular style sheet, etc. Would it be more efficient to store
> another session variable for the style sheet preference, rather than
> pulling out of the DB on every page? That way it would be one less
> query to the database. The first way is simpler, but the second way
> seems more optimized.
>
> But then this could be taken farther -- where do you draw the line with
> user preferences that are pulled out of the database each time they are
> needed, or user preferences that are stored in a session to save
> database activity?
>
> Since I have never written a database application before, I have no idea
> what kinds of performance changes occur with making sitewide adjustments
> like this. In other words, do -most- database-driven web sites store a
> ton of info in the session variable, or do they depend on the database
> itself to serve up this information on a page-by-page basis?
>
> Note that this setup is being run on Pentium II, 256MB RAM with approx
> 50 users total (only ten or so would ever be accessing the thing
> simultaneously, I imagine). It's not a public web site.
>
> Thanks for your thoughts,
>
> Erik
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>