创建 cookie:
$.cookie('the_cookie', 'the_value');
创建有效期7天的 cookie:
$.cookie('the_cookie', 'the_value', { expires: 7 });
创建有效期7天的整站 cookie:
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
读取 cookie:
$.cookie('the_cookie'); // => "the_value"
$.cookie('not_existing'); // => null
删除 cookie:
// cookie 存在是返回 true,否则返回 false$.removeCookie('the_cookie');
// path 路径要和创建的时候一致$.removeCookie('the_cookie', { path: '/' });