title: are $_COOKIE[] and RewriteRule on Apache broken when used together?
body: <p>I am having a weird bug when I set and get cookies after a url rewrite. This is the rewrite rule that I use:</p>
  
  <pre><code>RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)$ /$1/$2/ [R]
  RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+)/$ /index.php?destination=$1&amp;command=$2
  </code></pre>
  
  <p>And this is what I do to print the cookie:</p>
  
  <pre><code>var_dump($_COOKIE);
  </code></pre>
  
  <p>I also have a login which sets the proper cookies, and a logoff which expires the cookies.</p>
  
  <p>Login:<code>setcookie("USERNAME", "usernamestring", time()+3600);</code></p>
  
  <p>Logoff:<code>setcookie("USERNAME", "0", time()-3600);</code></p>
  
  <p>When I visit www.remoteaccessnow.com, the cookies are null.
  When I visit www.remoteaccessnow.com/accounts/, the cookies are not null.</p>
  
  <p>This is done during the same session. The bug happens in chrome 9, firefox 3+ and IE8.</p>
  
  <p>If I use no rewrite rule at all, there is no problem and the cookies are consistent throughout the "sub-urls". I do not know what is causing this problem. It seems that www.remoteaccessnow.com and www.remoteaccessnow.com/accounts/ are seen as two different domain by the "cookie processor". </p>
  
  <p>I am looking for advice on how to keep the cookies consistent for all sub urls of my domain.</p>