More on Setting Cookie in Head
-
So coldforged help me get the basics working. Thanks so much! However, while this seems to be working ok most of the time, when I try to look at a post, the cookie I am writing to is reset to default. I have posted the code below. Any thoughts would be great.
A little note, inorder to load different themes, and different colors for each theme, I use the folowing to set the theme dir, the color dir of that theme, and the font size.
Let me know. Thanks.
//This Controls Theme Choice
if (isset($_GET['theme'])){
setcookie ('styletheme', $_GET['theme'], time()+31536000, '/', 'localhost', '0');
$theme = $_GET['theme'];
} elseif (isset($_COOKIE['styletheme'])) {
$theme=$_COOKIE['styletheme'];
} else {
setcookie ('styletheme', 'beach', time()+31536000, '/', 'localhost', '0');
$theme = 'beach';
}//This Controls Color
if (isset($_GET['color'])){
setcookie ('stylecolor', $_GET['color'], time()+31536000, '/', 'localhost', '0');
$color = $_GET['color'];
} elseif (isset($_COOKIE['stylecolor'])) {
$color=$_COOKIE['stylecolor'];
} else {
setcookie ('stylecolor', 'color-1', time()+31536000, '/', 'localhost', '0');
$color = 'color-1';
}//This Controls Font Size
if (isset($_GET['set'])){
setcookie ('sitestyle', $_GET['set'], time()+31536000, '/', 'localhost', '0');
$sitestyle = $_GET['set'];
}
else if (isset($_COOKIE['sitestyle'])) {
$sitestyle=$_COOKIE['sitestyle'];
} else {
setcookie ('sitestyle', 'small', time()+31536000, '/', 'localhost', '0');
$sitestyle = 'small';
}
- The topic ‘More on Setting Cookie in Head’ is closed to new replies.