I'm using the jQuery cookie plugin to read/write/delete cookies. I'm using cookies to store points on a graph that the user plotted on top of a canvas. I'm allowing the user to store the plotted points along with a name in the cookie, I'm also listing the saved cookies so that they can redraw their saved points on the graph.
I was originally saving and reloading the points from cookies by naming each cookie with a sequential number $.cookie("_1")
, $.cookie("_2")
, etc and this worked. Problems start when user deletes a cookie and the sequential numbering breaks.
I would like to save the cookie using the name that the user gives to the plotted points, so basically saving cookies with arbitrary names. If I do this is it possible to read all domain cookies if I don't know their names?
You don't need jQuery for this. You can read all your cookies by accessing document.cookie
and parsing accordingly.
See an example here.
I don't know about calling all domain cookies, but you could always store the cookie with a name you choose and then make the value of the cookie be "name,x,y" or something. Just an idea as an alternative to trying to pull all domain cookies.
EDIT:
Also, this cookies plugin wiki shows that you can easily get a filtered list of cookies. So you could throw on an identifier to the name of the cookie "mysite+name"
and then use .slice
to take it back off after you get your filtered list.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With