title: Reading a cookie with jquery that was set by PHP
body: <p>I'm trying to set a cookie in PHP, and then have my JavaScript/jQuery read it. As I've been trying to research the issue I've seen some people talk about server side vs. client side cookies, and other people saying cookies are just cookies and there's no difference. What I do know is that PHP sees the cookies, and JavaScript doesn't.</p>
  
  <p>Here's a simplified version of the PHP file that builds the page and sets the cookies.</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;?php 
      setcookie("card", "", time()+900, '/');
  ?&gt;
  &lt;html&gt;
  &lt;body&gt;
         &lt;?php 
              $card = "a string I want in my cookie";
              $_COOKIE['card'] = $card;
  
              foreach($_COOKIE as $c =&gt; $c_value)
              {
                  echo "Cookie named " . $c . " has value " . $c_value . "&lt;br/&gt;";
              }
          ?&gt;
      &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="https://cdn.jsdelivr.net/npm/jquery.cookie@1.4.1/jquery.cookie.min.js"&gt;&lt;/script&gt;
      &lt;script type = "text/javascript" src = "script.js"&gt;&lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This will correctly show the name and value of the cookie on my page. So I know I'm setting something.</p>
  
  <p>But when my JavaScript runs, I don't seem to have any cookies. I tried a couple different ways to get to the value of either all cookies, or just a single target part of the cookie:</p>
  
  <pre><code>var all_cookies = document.cookie;
  var aCard = $.cookie('card');
  </code></pre>
  
  <p>all_cookies shows up with a value of "" when I debug, and aCard just stays undefined. </p>
  
  <p>So do I need to set the cookies differently with PHP? Or read them differently with either JavaScript or jQuery?</p>