Create session cookie:
$.cookie(‘name‘, ‘value‘);
Create expiring cookie, 7 days from then:
$.cookie(‘name‘, ‘value‘, { expires: 7 });
Create expiring cookie, valid across entire site:
$.cookie(‘name‘, ‘value‘, { expires: 7, path: ‘/‘ });
Read cookie:
$.cookie(‘name‘); // => "value"
$.cookie(‘nothing‘); // => undefined
Read all available cookies:
$.cookie(); // => { "name": "value" }
Delete cookie:
// Returns true when cookie was successfully deleted, otherwise false
$.removeCookie(‘name‘); // => true
$.removeCookie(‘nothing‘); // => false
// Need to use the same attributes (path, domain) as what the cookie was written with
$.cookie(‘name‘, ‘value‘, { path: ‘/‘ });
// This won‘t work!
$.removeCookie(‘name‘); // => false
// This will work!
$.removeCookie(‘name‘, { path: ‘/‘ }); // => true
官网:https://github.com/carhartl/jquery-cookie#readme
下载:http://files.cnblogs.com/files/helifei/jquery.cookie.zip
原文:http://www.cnblogs.com/helifei/p/4997459.html