title: Set cookie (with JS) for whole domain not specific page
body: <p>I have a simple little script which I am using to set a cookie:</p>
  
  <pre class="lang-js prettyprint-override"><code>function setCookie(cname, cvalue, exdays) {
      var d = new Date();
      d.setTime(d.getTime() + (exdays*24*60*60*1000));
      var expires = "expires="+d.toUTCString();
      document.cookie = cname + "=" + cvalue + "; " + expires;
  }
  </code></pre>
  
  <p>The problem I have this cookie is only set on one page, not across the whole domain.</p>
  
  <p>How can I adjust this function so that the cookie remains across the whole domain?</p>