I'm using jquery and I was wondering how do I retrieve a certain cookie value if I have multiple values, something like this:
$.cookie("name",[email,loc], { path: '/', ex开发者_Python百科pires: 60 });
How do I retrieve loc value?
Note: email and loc are set as variables.
I know you can get values by
$.cookie("name");
but i just want loc, not email and loc.
Try $.cookie("name")[1]
.
But nobody can tell you for sure without knowing which plugin you are using (it has to do some serializing/deserializing since cookies only contain plaintext - no arrays, objects, etc).
That looks like jQuery's plugin. See the json section of https://github.com/carhartl/jquery-cookie/blob/master/README.md on multiple values. You'd have to use curly instead of list brackets.
On the other hand you could parse the string yourself or create several cookies.
精彩评论