I've had a cookie based style switcher on my site for a while now and it works great.
switcher.php accessed like switcher.php?set=red
I'm changing things and want to be able to change a snippet in multiple locations in the template rather than tracking down the class and making changes to several .css filesPHP Code:<?php
setcookie ('theirstyle', $set, time()+31536000,
'/', 'mydomain.com', '0');
header("Location: $HTTP_REFERER");
?>
I created the following to try to check if the cookie was set and what it was equal to but I'm missing something because only red.gif is showing if blue or green are set.
Does anything stand out to anyone? Thank youPHP Code:<?php
switch ('theirstyle') {
case (isset($_COOKIE['theirstyle']) || $set == 'red'):
echo '<img src="images/red.gif" border="0" alt="alt text here">';
break;
case (isset($_COOKIE['theirstyle']) || $set == 'blue'):
echo '<img src="images/blue.gif" border="0" alt="alt text here">';
break;
case (isset($_COOKIE['theirstyle']) || $set == 'green'):
echo '<img src="images/green.gif" border="0" alt="alt text here">';
break;
default:
//.. anything can go here
break;
}
?>



Reply With Quote



Bookmarks