php - JSON Encode and Decode -


i have array this:

array (     [utm_source] => website     [utm_medium] => fbshare     [utm_campaign] => camp1     [test_cat] => red     [test_sub] => category     [test_ref] => rjdepe ) 

which json_encode , put cookie. take cookie , want decode blank screen. confused wrong. me 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 such:

$value = array(     'utm_source' => 'website',     'utm_medium' => 'fbshare',     'utm_campaign' => 'camp1',     'test_cat' => 'red',     'test_sub' => 'category',     'test_ref' => 'rjdepe' ); $value = base64_encode(json_encode($value)); setcookie("testcookie", $value, time()+3600); 

other page:

$cookie = $_cookie['testcookie']; $cookie = json_decode(base64_decode($cookie)); print_r($cookie); 

Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -