I have an array like this:
Array (
[utm_source] => website
[utm_medium] => fbshare
[utm_campaign] => camp1
[test_cat] => red
[test_sub] => Category
[test_ref] => rjdepe
)
which I json_encode 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:
{"utm_source":"website","utm_medium":"fbshare","utm_campaign":"camp1","test_cat":"red","test_sub":"Category","test_ref":"dodere"}
Any ideas?
Edit:
My code:
$value = array(
'utm_source' => 'website',
'utm_medium' => 'fbshare',
'utm_campaign' => 'camp1',
'test_cat' => 'red',
'test_sub' => 'Category',
'test_ref' => 'rjdepe'
);
$value = json_encode($value);
setcookie("TestCookie", $value, time()+3600);
Other Page:
$cookie = $_COOKIE['TestCookie'];
$cookie = json_decode($cookie);
print_r($cookie);
Try base64_encoding it like such:
Other Page: