I was wondering if it was possible to create a cookie (using jquery.cookie) which looks like this in php:
$_COOKIE['124']['ctns'] => 12
$_COOKIE['124']['units'] => 2
OR
$_COOKIE['124'] => array( 'ctns' => 12, 'units' => 2 )
Currently I’ve created the cookie which looks like:
$_COOKIE['124-ctns'] => 12
$_COOKIE['124-units'] => 2
But I’m realising that’s not going to work for what I need.
The code I’m using (jquery) is:
$.cookie('124-ctns', 12, { path: '/' });
$.cookie('124-units', 2, { path: '/' });
Any help would be appreciated 🙂
You can’t. Cookies ONLY store strings, not objects.
You can convert the objects to JSON so the code looks something like
Then the variable n124 should be the object so you can get the variables like
n124.ctns
n124.units