title: Store form data as single cookie
body: <p>I have a cookie set on my site which tells me what type of device people are using.</p>
  
  <p>the values are as follows</p>
  
  <ul>
  <li>S</li>
  <li>M  </li>
  <li>T </li>
  <li>D</li>
  </ul>
  
  <p>the value of the cookie can be either MS, TS or DS.</p>
  
  <p>I want to create a form where the user can update there cookie manually and when they submit the form it will update the cookie but i also want the form to already have the current cookie values selected.</p>
  
  <p>i tried this code but i get a undefined cookie value.</p>
  
  <p>Heres the form</p>
  
  <pre><code>&lt;form name="devicePrefs"&gt;
      &lt;input type="radio" name="deviceType" value="D"&gt;Desktop&lt;br&gt;
      &lt;input type="radio" name="deviceType" value="T"&gt;Tablet&lt;br&gt;
      &lt;input type="radio" name="deviceType" value="M"&gt;Mobile&lt;br&gt;
      &lt;input type="checkbox" name="skipSeat" value="S"&gt;Skip Seating Plan&lt;br&gt;
      &lt;input type="button" value="Set to Cookie" onClick="storeValues()"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>here is the javascript i used</p>
  
  <pre><code> var today = new Date();
   var expiry = new Date(today.getTime() + 30 * 24 * 3600 * 1000); // plus 30 days 
   function setCookie(name, value) { 
      document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString(); 
   }
  
    function storeValues() { 
      setCookie("ATGDevicePrefs", devicePrefs.deviceType.value, devicePrefs.deviceType.skipSeat); 
    }
  </code></pre>
  
  <p>thanks in advance for any help.</p>