开发者

JQuery.cookies setting a key value pair

I'm trying to use the JQuery cookies library http://code.google.com/p/cookies/ But am not able to set key value 开发者_运维百科pairs within the cookie. I can't see how in the documentation, does anyone know how?

Thanks


Check out the JSON example in the link you referenced.

//JSON 
var jimData = {id: 1, name: 'jim'}; 
$.cookies.set( 'userdata', jimData ); //A cookie by the name 'userdata' now exists with a serialized copy of jimData 

var userData = $.cookies.get( 'userdata' ); //A variable named 'userData' now holds the unserialized object--should be identical to the variable 'jimData' 

So, userData should now have properties id with value 1 and name with value 'jim'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜