Setting variables in Sessions
Posted: Tue Jul 26, 2005 7:43 am
I've read up on sessions a little bit (...Yeah, sadly, I can't find a lot of information on it to benefit me). The only problem is that I haven't the slightest clue how to set a variable like I did using isset() and then being able to use the url blah.com/?variable=yadayadayada and have it actually work with the session.
My example:
I have a website (Gee, something unique every day!). It has the ability to change between seven themes (not including an additional theme that is "Printer Friendly") and also to change between two languages (English and Deutsch). Now, the old way I did it was without Sessions and I used conditionals with isset functions to detect the theme, but they also detected it via Cookies ($theme = |cookie|) or they'd automatically set a cookie (or in the case of languages, redirect to the index page to have the user set their own language).
Now, if I am going to kill off all the cookies (*tear*, i love cookies, they taste good), what do I have to do to implement Sessions to do the exact same thing. I kept screwing up the code with stuff like this:
And yes I opened and closed sessions, and I also tried having the $_SESSON part go on the left side, and the else "yada" = the session variable... But all I kept getting was "yadayadayada" instead of $_session variable, because I haven't a clue how to set variables, no doubt change them via links using sessions.
My example:
I have a website (Gee, something unique every day!). It has the ability to change between seven themes (not including an additional theme that is "Printer Friendly") and also to change between two languages (English and Deutsch). Now, the old way I did it was without Sessions and I used conditionals with isset functions to detect the theme, but they also detected it via Cookies ($theme = |cookie|) or they'd automatically set a cookie (or in the case of languages, redirect to the index page to have the user set their own language).
Now, if I am going to kill off all the cookies (*tear*, i love cookies, they taste good), what do I have to do to implement Sessions to do the exact same thing. I kept screwing up the code with stuff like this:
Code: Select all
if(isset($variable)) {
$variable = $_SESSION['variable']
} else {
$variable = "yadayadayada"
}