title: Why do I get undefined index while using cookie in PHP?
body: <p>If I use the following basic code</p>
  
  <pre><code>if (!defined('NAME_COOKIE') )
   define('NAME_COOKIE', "storedusername");
  
  $cookie_domain = ".".$_SERVER['HTTP_HOST'];
  
  setcookie(NAME_COOKIE, $username,time() + (86400),"/", $cookie_domain);
  print $_COOKIE[NAME_COOKIE];
  </code></pre>
  
  <p>The script dies during the print with undefined index error.  What am I doing wrong?</p>