title: SetCookie with Javascript
body: <p>I am trying to setCookie on a wordpress page load. Unfortunately nothing is happening when I added the script code below. I've been using this code in php <code>setcookie("gmp_", "1", strtotime( '+30 days' ), '/');</code> with no problems but now I'm trying to get the Javascript version to work. Am I overlooking something?</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  function setCookie(name,value,days) {
      if (days) {
          var date = new Date();
          date.setTime(date.getTime()+(days*24*60*60*1000));
          var expires = "; expires="+date.toGMTString();
      }
      else var expires = "";
      document.cookie = name+"="+value+expires+"; path=/";
  }
  setCookie('gmp_','1',30);    
  &lt;/script&gt;
  </code></pre>