title: Setting cookies with form input
body: <p>I am trying to make a username cookie using the user's input to a web form. However it's not working and I don't know why.  Do you know what the problem is?</p>
  <pre><code>&lt;form&gt;
      &lt;input type=&quot;text&quot; value=&quot;Enter Your Nickname&quot; id=&quot;nameBox&quot;&gt;
      &lt;input type=&quot;button&quot; value=&quot;Go!&quot; id=&quot;submit&quot; onClick=&quot;setCookie();&quot;&gt;
  &lt;form&gt;
  
  
  &lt;script&gt;
      var today = new Date();
      var expiry = new Date(today.getTime() + 30 * 24 * 3600 * 1000); // plus 30 days
  
      function setCookie(name, value){
          document.cookie=name + &quot;=&quot; + escape(value) + &quot;; path=/; expires=&quot; + expiry.toGMTString();
      }
      //this should set the UserName cookie to the proper value;
      function storeValues(form){
          setCookie(&quot;userName&quot;, form.submit.value);
          return true;
      }
  
  &lt;/script&gt;
  &lt;/body&gt;
  </code></pre>