title: How do you set a cookie to be accessible across the entire domain in Javascript
body: <p>I suppose there should be a way to set a cookie to be accessible from the entire domain nevermind from which directory you are setting the cookie. </p>
  
  <p>Say in mypage.com/blue/index.php y set the cookie "colour=blue;" this way: </p>
  
  <pre><code>document.cookie = "colour" + "=" + "blue" 
      + "; expires=" + expireDate.toGMTString() 
      + "; path=/";
  </code></pre>
  
  <p>Using this code, the cookie retrieval function in mypage.com/home.php can't access the content of the cookie. </p>
  
  <p>If it was just from first level directories that the cookie needs to be set, we would be ok by doing <code>path=../</code> instead of <code>path=/</code></p>
  
  <p>But how do you go about writing generic code that sets a cookie that is accessible from any page in that domain not minding how deep in the file structure is the page the cookie is being set from?</p>