I'm saving a cookie with json data. Example of echo $_COOKIE['data']
[{\"date\":1355249777,\"title\":\"junior\"},{\"date\":1355249747,\"title\":\"christopher\"},{\"date\":1355249139,\"title\":\"melfi\"},{\"date\":1355249123,\"title\":\"tony\"},{\"date\":1355248876,\"title\":\"carmela\"},{\"date\":1355248859,\"title\":\"meadow\"}]
The data was pure javascript, then passed by JSON.stringify
and then stored in the cookie. Now i need to convert it to a php array. I tried a json_decode
approach but it returns null. Any ideas? Thanks!
Try
json_decode(stripslashes($_COOKIE['data']));