Im attempting to store json objects in a cookie, but im running into a few problems.
I can create my object like this:
product = {
"name" : "prodname",
"quantity" : 4
}
i then save this object in my cookie. As more products are added (its a shopping basket) i add further strings by appending new objects onto the end of the cookie string (so i essentially have lots of small seperate objects) . Im having trouble getting the objects back out of the cookie string though. Both $.parseJSON and eval fail when i attempt to read the objects back from the cookie. Any help would be appreciated.
It should probably be like:
The
[]signifies an array. When you want add another product, you load it from the cookie, update the array, then save it again. If you wanted, you could skip the outer object and have the cookie just be the array.EDIT: Say
cookieStris your cookie.