I read and set cookies from the front-end, I mean this:

notes = JSON.parse($.cookie(cookieName)); $.cookie(cookieName, JSON.stringify(notes), {expires: 30, path: '/'}); 

Where notes is a one-dimensional array of var notes = [] .

Question: how to install the same array in cookies from php so that they are read by jquery. I tried this:

 setcookie($cookieName, json_encode($notes), time() + 3600, '/'); 

Does not exceed

UPD: $ notes = array ();

  • Try setcookie($cookieName, serialize(json_encode($notesTop)), time() + 3600, '/'); - mix
  • If json_encode() does not work, then do it without it. When you pull out, then make an encode. By the way, when you try to read this cookie, before reading you need to arrayize the array in the same way, that is, $cook = unserialize($_COOKIE['cookie_name']); . - mix

0