注意:如果不设置path,默认为当前路径,新建cookie
$.cookie('name', 'value');
新建带限制时间cookie
$.cookie('name', 'value', { expires: 7 });
新建限制时间和路径cookie,
$.cookie('name', 'value', { expires: 7, path: '/' });
读取cookie
$.cookie('name'); // => "value"
$.cookie('nothing'); // => undefined
读取所有可用cookie$.cookie(); // => { "name": "value" }
删除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