title: Setting a Cookie if Hash is Valid in URL
body: <p>what I'm doing is passing a hash in the URL from <code>page1.php</code> to <code>page2.php</code> which has been working fine so far but instead of setting <code>$valid</code> to <code>TRUE</code> I want to set a cookie.</p>
  
  <p><strong>Currently I have the code working like this:</strong></p>
  
  <pre><code>if ($hash === md5($key.$test_time)) $valid = TRUE;
  </code></pre>
  
  <p><strong>To set the cookie instead I tried this:</strong></p>
  
  <pre><code>if ($hash === md5($key.$test_time))
  //set "Cookie" for 24 hours
  $cookie_value = "Cookie";
  setcookie("Placed", $cookie_value, time()+86400);
  </code></pre>
  
  <p><strong>I am getting these errors:</strong></p>
  
  <blockquote>
    <p>Notice: Undefined variable: cookie_value in /Dev/sites/files/page2.php on line 19 </p>
  </blockquote>
  
  <p>and</p>
  
  <blockquote>
    <p>Warning: Cannot modify header information - headers already sent by (output started at /Dev/sites/files/page2.php:19) in /Dev/sites/files/page2.php on line 19</p>
  </blockquote>
  
  <p>How do I fix this so I can set a cookie instead of a value?</p>