Page 1 of 1

Session variables vs. repulling data

Posted: Thu Mar 04, 2010 5:30 am
by Jackolantern
Are there limitations or bottlenecks on session variables? I am trying to figure out if it would be a better to store several different session variables at player login so as to save them between pages. The other option I can see is to requery for them on each page needed, and only store the player's name in the session variables. If you could save those MySQL queries (and pulling all the player data is a fairly big one in PBBG terms) for every script access, that could be a large savings, but I don't know if there is some negative to session variables that could negate the pros of using all session variables.

Re: Session variables vs. repulling data

Posted: Thu Mar 04, 2010 10:19 am
by Torniquet
well usually a session only lasts for about 24 minutes. you would have to alter it in the .htaccess to either last longer, or store sessions in a folder on the server.

i cant find the link i had which explained how to do it all, but if i remember correctly i googled 'extending php sessions'

Re: Session variables vs. repulling data

Posted: Thu Mar 04, 2010 12:30 pm
by Jackolantern
Hmmm...is WAMP atypical then of web servers, because I can actually close my browser window and come back the next day and I am still logged in with all of my session variables (something I thought was going to be a problem I was going to have to fix)?

Re: Session variables vs. repulling data

Posted: Thu Mar 04, 2010 1:25 pm
by OldRod
That is probably your browser saving your info, not WAMP.

I told Firefox not to save my info and I have to re-log in every time I open the browser. I stay logged in until I close the browser or click 'logout', but it doesn't remember it when the browser is closed.

Re: Session variables vs. repulling data

Posted: Thu Mar 04, 2010 11:07 pm
by Jackolantern
OldRod wrote:That is probably your browser saving your info, not WAMP.

I told Firefox not to save my info and I have to re-log in every time I open the browser. I stay logged in until I close the browser or click 'logout', but it doesn't remember it when the browser is closed.
Ahhh, that makes sense. But doesn't the browser save cookies that only save a session ID? The actual session variable values are stored on the server, right? That was my understanding. If the actual session variables are stored on the client's computer, I have some re-coding to do. :o

Re: Session variables vs. repulling data

Posted: Thu Mar 04, 2010 11:39 pm
by Torniquet
there are ways of setting up your server to store session variables on there, but it doesnt usually keep them without being told to... or atleast thats how i understand it lol.

although i have just googled it, and seems others have had the same issue of sessions being kept open when a browser is closed (i havnt had that problem though :s)

what browser are you using??

Re: Session variables vs. repulling data

Posted: Fri Mar 05, 2010 12:05 am
by Jackolantern
Torniquet wrote:there are ways of setting up your server to store session variables on there, but it doesnt usually keep them without being told to... or atleast thats how i understand it lol.

although i have just googled it, and seems others have had the same issue of sessions being kept open when a browser is closed (i havnt had that problem though :s)

what browser are you using??
I am using Firefox for initial testing.

EDIT: After doing some checking online, in the PHP manual and a couple of PHP books, I found that session variables are always stored on the server, and only a session ID or cookie is stored on the client-side, depending on how you configure it to be stored in your code (which is how I thought sessions worked). However, more safeguards need to be taken to ensure they are secure, such as using cookies to store session IDs and enabling SSL on your website.