Erik:
If I could paraphrase your question, it'd be, "is it better to leave info in session 
vars or use db calls" - if that's right, I'd say db call for your particular need is 
faster/easier, as you'll be accessing the db anyway (getting their personal info).  
Just add a style sheet preference field to the db, and call it along with the other 
user info, and have the php write the correct css include call. 
>From the sounds of it, with only 10 active users, you won't have any performance 
>issues either way you work it out.

Sean
-----Original Message-----
From: Erik Price [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 23, 2002 10:30 AM
To: PHP (E-mail)
Subject: [PHP] what vars should go in session vars?

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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to