title: JSON Encode and Decode
body: <p>I have an array like this:</p>
  
  <pre class="lang-none prettyprint-override"><code>Array (
      [utm_source] =&gt; website
      [utm_medium] =&gt; fbshare
      [utm_campaign] =&gt; camp1
      [test_cat] =&gt; red
      [test_sub] =&gt; Category
      [test_ref] =&gt; rjdepe
  )
  </code></pre>
  
  <p>which I <code>json_encode</code> and put into a cookie. I take it from the cookie and now want to decode it but I get a blank screen. I am confused as to what is wrong. To me this JSON looks correct:</p>
  
  <pre><code>{"utm_source":"website","utm_medium":"fbshare","utm_campaign":"camp1","test_cat":"red","test_sub":"Category","test_ref":"dodere"}
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Edit:</p>
  
  <p>My code:</p>
  
  <pre><code>$value = array(
      'utm_source' =&gt; 'website',
      'utm_medium' =&gt; 'fbshare',
      'utm_campaign' =&gt; 'camp1',
      'test_cat' =&gt; 'red',
      'test_sub' =&gt; 'Category',
      'test_ref' =&gt; 'rjdepe'
  );
  $value = json_encode($value);
  setcookie("TestCookie", $value, time()+3600);
  </code></pre>
  
  <p>Other Page:</p>
  
  <pre><code>$cookie = $_COOKIE['TestCookie'];
  $cookie = json_decode($cookie);
  print_r($cookie);
  </code></pre>