title: How to modify Cookie from Ajax call
body: <p>I have this code:</p>
  
  <pre><code>window.onload = function() {
          document.cookie = 'foo=bar; expires=Sun, 01 Jan 2012 00:00:00 +0100; path=/';
          var xhr = new XMLHttpRequest();
          xhr.open("GET", "/showcookie.php",true);
          xhr.setRequestHeader("Cookie", "foo=quux");
  
          xhr.setRequestHeader("Foo", "Bar");
          xhr.setRequestHeader("Foo", "Baz");
  
          xhr.withCredentials = true;
          var pre = document.getElementById('output');
          xhr.onreadystatechange = function() {
              if (4 == xhr.readyState) {
                  pre.innerHTML += xhr.responseText + "\n";
              }
          };
          xhr.send(null);
      };
  </code></pre>
  
  <p>and this /showcookie.php</p>
  
  <pre><code>&lt;?php
  
  print_r($_COOKIE);
  
  ?&gt;
  </code></pre>
  
  <p>and it always show</p>
  
  <pre><code>Array
  (
      [Host] =&gt; localhost
      [User-Agent] =&gt; 
      [Accept] =&gt; 
      [Accept-Language] =&gt; pl,en-us;q=0.7,en;q=0.3
      [Accept-Encoding] =&gt; gzip,deflate
      [Accept-Charset] =&gt; ISO-8859-2,utf-8;q=0.7,*;q=0.7
      [Keep-Alive] =&gt; 115
      [Connection] =&gt; keep-alive
      [foo] =&gt; Baz
      [Referer] =&gt;
      [Cookie] =&gt; foo=bar
  )
  
  Array
  (
      [foo] =&gt; bar
  )
  </code></pre>
  
  <p>I'm using Firefox 3.6.13, Opera 11.00 and Chromium 9.0 on Ubuntu. </p>
  
  <p>Is anybody have the same problem or maybe it's impossible to modify Cookie header.</p>