dprichard Posted August 19, 2008 Share Posted August 19, 2008 Okay, I have a web app I wrote a while back and it has a bunch of information I use on every page. Username, First Name, Last Name, Status, etc. I have a query in an include at the top of the page so essentially it is querying this information every page as the user goes from page to page. This has worked well for the few small companies we have on it, but now we have the potential for a company to start using it with 10k plus people. I am trying to limit the amount of queries made on the database, but I have like 10 different items I would have to save in sessions. Is it common practice to have 10 session variables saved off and just call them from page to page. I am trying to figure out how to do this with the least amount of load on the server. I really appreciate any thoughts or input on this. Link to comment https://forums.phpfreaks.com/topic/120386-how-would-you-handle-this-query-vs-sessions-vs-cookies/ Share on other sites More sharing options...
akitchin Posted August 19, 2008 Share Posted August 19, 2008 clearly, saving the information into the session is far less intensive than querying for that information on every single page for every single user. you would be wise to do this to save the database a great deal of strain. if you think about it, the more frequently you use the information, the more reason there is for storing the information. Link to comment https://forums.phpfreaks.com/topic/120386-how-would-you-handle-this-query-vs-sessions-vs-cookies/#findComment-620307 Share on other sites More sharing options...
dprichard Posted August 19, 2008 Author Share Posted August 19, 2008 So if I start getting tons and tons of users will storing all these sessions cause a strain as well over time or are they pretty much a non issue? Link to comment https://forums.phpfreaks.com/topic/120386-how-would-you-handle-this-query-vs-sessions-vs-cookies/#findComment-620312 Share on other sites More sharing options...
akitchin Posted August 19, 2008 Share Posted August 19, 2008 well they are stored on the hard disk, which means they can be directly accessed rather than having to go through a db server intermediary. the way i understand it, sessions are cleared from the disk on timeout, so they don't accumulate over time (i don't think). that's something a bit of googling on your server of choice might answer for you. i can say for certain that sessions will cause less of a strain over time than querying the db on every page for every user. Link to comment https://forums.phpfreaks.com/topic/120386-how-would-you-handle-this-query-vs-sessions-vs-cookies/#findComment-620315 Share on other sites More sharing options...
revraz Posted August 19, 2008 Share Posted August 19, 2008 Sessions are cleared by the GC (garbage collector). The php.ini holds the settings for how often it runs as well as when the duration the session can remain inactive before the GC will delete it. Link to comment https://forums.phpfreaks.com/topic/120386-how-would-you-handle-this-query-vs-sessions-vs-cookies/#findComment-620317 Share on other sites More sharing options...
dprichard Posted August 19, 2008 Author Share Posted August 19, 2008 Kewl, great info. Thank you so much for your help! Link to comment https://forums.phpfreaks.com/topic/120386-how-would-you-handle-this-query-vs-sessions-vs-cookies/#findComment-620327 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.