title: How do I set the HttpOnly flag of a cookie with javascript?
body: <p>I'm trying to create a cookie, with the HttpOnly flag enabled.</p>
  
  <p>While there seems to be a plethora of resources about how to do it in Java and .Net, I need to do it in javascript.</p>
  
  <p>Here is my (currently failing) function</p>
  
  <pre><code>createCookie = function(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+"; domain=my.domain.com; path=/; HttpOnly;";
  </code></pre>
  
  <p>Thanks - </p>