title: Accessing cookies, hopefully in JavaScript
body: <p>I am working on a Firefox add-on that will allow users (all of whom are part of a specific group; this add-on is very limited in audience scope) to see the status of their authentication cookie from the status bar. We all have to authenticate to access work-related sites, but we get no warning when the cookie expires, so this causes annoying and sometimes drastic interrupts in work flow. Eventually, this add on will allow us to submit our credentials from the status bar without having to go to do any reloads or redirects, but for now, I just want to see it show the status.</p>
  
  <p>I have been looking at the Mozilla developer pages at nsICookie, nsICookie2, nsICookieManager, etc, and it doesn't make very clear sense how any of it fits into JavaScript or XUL or anything else.</p>
  
  <p>Ideally, I'd just like a way for the JavaScript to go outside of the document and get the cookie string for a domain I specify. If I could do that, it would allow the code to possibly be ported over to other browsers (Safari and Chrome, in particular). But if this must be browser specific, then I would at least like to know the method for checking if the cookie exists in Firefox without any bells and whistles of setting or removing.</p>
  
  <p>Simply put, I want a way to say:</p>
  
  <pre><code> if (cookieExists("sample.com", CookieName)) {
       alert("You're signed in!");
   } else {
       alert('Go sign in, you fool!');
   }
  </code></pre>
  
  <p>What is the easiest/most portable way of doing this (browser-side, of course)?</p>