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 have to set the value for the key to access with $_COOKIE:
$_COOKIE
setcookie('items['.$_POST['id'].']', 'some_value');
Link to manual