How do I create and read a value of array of objects from cookie in JavaScript?
[{name="sss", age="33"}
, {name="ll", age="22"}]
How do I create and read a value of array of objects from cookie in JavaScript?
[{name="sss", age="33"}
, {name="ll", age="22"}]
You'll have to "stringify" the array and store the string in the cookie, something like:
var myArray = [{name="sss", age="33"} , {name="ll", age="22"}];
var cookieStr = JSON.stringify(myArray);
// Do whatever you want with your cookie
Then you get the string back out later (as a string) and parse it:
var cookieStr = ...; // Get it out of the cookie
var myArray = JSON.parse(cookieStr);