title: Using cookies and php to change style sheets(CSS)
body: <p>I have some code that works and changes the style sheet using a form. That work as long as you keep the browser window open. You can got to a different site come back and the style will be the one you selected, thats fine but if u close the browser and come back it will be set to the default. Is this due to the fact that I am starting a new session each time or is due to the fact I have not set how long the cookie is valid? Thats question one. </p>
  
  <p>Question 2 is that I have the drop down menu that currenty works and chooses the correct style sheet but I also have some radio buttons for text size. I want these to be incorperated but they will work using a different style sheets that simply have just the text sizes in so the default text size is standard and the user can change them along with the style sheet but they work indepdantly. Could anyone suggest some coding thanks. </p>
  
  <p>Below is what I am currently working with. Cheers</p>
  
  <p>Php setting the style: 
       
       
  
  <pre><code>  if (isset($_COOKIE["selectedStyle"])) // has the cookie already been set
    {
      $style=$_COOKIE["selectedStyle"];
    }else{
  $style = spring;
  }
  
    if (isset($_POST["changeStyle"]))  // changing the style
    {
      $style=$_POST["changeStyle"];
    }
  
    setcookie("selectedStyle",$style); // update or create the cookie
   ?&gt;
  </code></pre>
  
  <p>Form with drop down that works and radio buttons for the text changer: </p>
  
  <pre><code>&lt;div id="headerInfo"&gt;
  &lt;p&gt;&lt;strong&gt;User Controls&lt;/strong&gt;&lt;/p&gt;
    &lt;form method="post" action="&lt;?= $_SERVER["PHP_SELF"];?&gt;"&gt;
  Select Page Style:&lt;br/&gt;
  &lt;select name="changeStyle"&gt;
  &lt;option value="spring"&gt;Spring (Green)&lt;/option&gt;
  &lt;option value="summer"&gt;Summer (Yellow)&lt;/option&gt;
  &lt;option value="winter"&gt;Winter (Blue)&lt;/option&gt;
  &lt;option value="autumn"&gt;Autumn (Orange)&lt;/option&gt;
  &lt;/select&gt;
  &lt;input type="submit" name="submitstyle" value="Set Style"&gt;
    &lt;/form&gt;
      &lt;form method="post" action="&lt;?= $_SERVER["PHP_SELF"];?&gt;"&gt;
  Select Font Size:&lt;br/&gt;
  &lt;span class="smallText"&gt;A&lt;/span&gt;&lt;input type="radio" name="changeFontSize" value="small"/&gt;
  &lt;span class="standardText"&gt;A&lt;/span&gt;&lt;input type="radio" name="changeFontSize" value="standard"/&gt;
  &lt;span class="largeText"&gt;A&lt;/span&gt;&lt;input type="radio" name="changeFontSize" value="large"/&gt;
  &lt;span class="xLargeText"&gt;A&lt;/span&gt;&lt;input type="radio" name="changeFontSize" value="extraLarge"/&gt;
  &lt;/select&gt;
  &lt;input type="submit" name="submitfont" value="Set Size"&gt;
  &lt;/div&gt;
  </code></pre>