Page 1 of 1

Sessions

Posted: Thu Feb 21, 2008 8:42 am
by QbertsBrother
so i am making a website and i was wondering what the best way to go about this would be.

i am making a website for a local store here. now i have set up a session and i have stored some values in session variables such as the ip address and stuff like that. now i have some values that are constants such as the stores address and what not. so i have done this:

Code: Select all

$storeaddress = '1234 anystreet';
i did that because i dont want to have to write the address out everywhere i need to display it. so my question is this. is it better to store things like that the way that i did it? or should i make it a session variable? it was my thought that session variables should be values that are unique to the session and since the address is a constant i should not store it as a session variable.

any input on this situation would be great.

also is there a way to out put the session values for everyone that is on the site? if i do this:

Code: Select all

print_r($_SESSION);
i only see my session and i would like to see the others.

thanks

Re: Sessions

Posted: Thu Feb 21, 2008 9:09 am
by liljester
You should use sessions when you want to store data between page clicks. For example: If I create a login system to my website, I need atleast some of that users information to persist while they are logged in, so i can store their user id in a session variable, and then on subsequent page loads, i can pull thier information from a database using thier user id.

Now that being said, you can store things such as location, email address, pretty much anything you want as a session variable. but if you already have the store's address defined and its not going to change, it doesnt really make sense to use a session for storage.

you cannot see sessions from other people.