title: How to write & print a PHP cookie in the same request?
body: <p>I'm not sure why, but the following doesn't seem to work as expected:</p>
  
  <pre><code>&lt;?php
      setcookie('my_cookie', $_GET['v'], time() + (86400 * 7)); 
      echo $_COOKIE['my_cookie'];
  ?&gt;
  </code></pre>
  
  <p>If you put this in a file on a PHP web server and call it with a query of <code>yourdomain.com/index.php?v=value</code>. The value only gets printed to the page on the 2nd request. Why not on the 1st?</p>