如题,对cookie中的某些内容进行读取、设置和删除等方法?
解决方案
无官方支持,有插件实现。
比如:https://github.com/carhartl/jquery-co...
创建 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: '/' });