我有一个这样的数组:
Array (
[utm_source] => website
[utm_medium] => fbshare
[utm_campaign] => camp1
[test_cat] => red
[test_sub] => Category
[test_ref] => rjdepe
)
我json_encode
把它放进饼干里。我从 cookie 中取出它,现在想解码它,但我得到一个空白屏幕。我对出了什么问题感到困惑。对我来说,这个 JSON 看起来是正确的:
{"utm_source":"website","utm_medium":"fbshare","utm_campaign":"camp1","test_cat":"red","test_sub":"Category","test_ref":"dodere"}
有任何想法吗?
编辑:
我的代码:
$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);
其他页面:
$cookie = $_COOKIE['TestCookie'];
$cookie = json_decode($cookie);
print_r($cookie);