rossh Posted December 7, 2006 Share Posted December 7, 2006 Hi i'm trying to get a site working with different styles and i'm changing variables in one style.php file which was working fine, however every now and again the old style reappears on random pages? Don't know if it's my conditional statements or a cache problem? I have various areas on the site that are secure https and i had to add the domain for the cookie to work in the secure areas. I could probably figure it out if the error was not random. Also i'm guessing this is not the best solution if anyone can let me know the best way to go about this i would really appreciate it.ThanksRStyle.php<?phpsession_start(); header('Content-type: text/css');if ($_SESSION['style'] == ""){ $logo = "../image/logo-purple.gif";}else{ $logo = "../image/logo-".$_SESSION['style'].".gif";}if ($_SESSION['color'] == ""){ $color = "#9B83B7";}else{ $color = $_SESSION['color'];}?>header.php session_start(); require_once ("functions.php"); if ($_SESSION['style'] == ""){ $_SESSION['style'] = "purple"; } if ($_COOKIE["style"] != ""){ $_SESSION['style'] = $_COOKIE["style"]; } if(isset($_GET['style']) && $_GET['style']!=""){ $_SESSION['style'] = $_GET['style']; } setcookie ("style"); //Delete existing entry setcookie('style', $_SESSION['style'], time() + (86400 * 30), '/', '.domain.com'); //.domain.com to deal with https $style = $_SESSION['style']; switch ($style){ case "purple": $_SESSION['color'] = "#9B83B7;"; break; case "green": $_SESSION['color'] = "#8DC63F;"; break; case "pink": $_SESSION['color'] = "#EC008C;"; break; case "orange": $_SESSION['color'] = "#F26521;"; break; case "brown": $_SESSION['color'] = "#726257;"; break; case "blue": $_SESSION['color'] = "#448CCB;"; break; case "print": $_SESSION['color'] = "#000;"; break; default: $_SESSION['color'] = "#9B83B7;"; } Quote Link to comment Share on other sites More sharing options...
matto Posted December 7, 2006 Share Posted December 7, 2006 It could probably be done better if you created a few different CSS files and depending on which style needs to change just have the $_SESSION variable store the associated CSS file name which would change the following line in all your HTML documents<link rel="stylesheet" type="text/css" href="some_theme.css"/> Quote Link to comment Share on other sites More sharing options...
rossh Posted December 8, 2006 Author Share Posted December 8, 2006 Hi thanks for getting back to me. I did that originally but it was getting difficult to update if i needed to make changes to the stylesheet. Any ideas why random pages whould revert to the previous style? I've printed the session and cookie variables when this happens and they are the have the correct value but the wrong style?ThanksR Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.