I need to update a cookie. I do that in a php file called via ajax. This is is the code:
setcookie(\'items[\'.$_POST[\'id\'].\']\');
The cookie
You cannot set and access a cookie in the same instance/page. You have to do a redirect or refresh after setting it.
In addition, you should do something like this instead :
setcookie("id","items['.{$_POST['id']}.']");