title: Cookies aren't persisting in PHP?
body: <h3>How do I get the cookies to persist in php?</h3>
  <hr />
  <p><strong>give_cookie.php</strong></p>
  <pre><code>&lt;?php
      if (!isset($_COOKIE[&quot;muffin&quot;]))
          setcookie(&quot;muffin&quot;, &quot;55&quot;, 100 * 60 * 60 * 24 * 30);
      $_COOKIE[&quot;lid&quot;]=true;
  ?&gt;
  </code></pre>
  <p><strong>jar.php</strong></p>
  <pre><code>&lt;?php
      var_dump($_COOKIE);
      if($_COOKIE[&quot;lid&quot;])
          echo &quot;open&quot;;
  ?&gt;
  </code></pre>
  <hr />
  <p>Running the code in that order gives me output:</p>
  <blockquote>
  <p>array(0) { } Notice: Undefined index: lid in jar.php on line 3</p>
  </blockquote>
  <p>Embedding the code from <code>jar.php</code> in <code>give_cookie.php</code> gives me output:</p>
  <blockquote>
  <p>array(1) { [&quot;lid&quot;]=&gt; bool(true) } open</p>
  </blockquote>