// 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
2017-08-24
path 是保存cookie值的路徑,默認與創(chuàng)建頁的路徑一致
expires 是有限日期,單位是(天)
2017-07-30
創(chuàng)建會話cookie:
$.cookie('name', 'value');
創(chuàng)建到期的cookie,然后7天:
$.cookie('name', 'value', { expires: 7 });
創(chuàng)建有效到期cookie,整個網(wǎng)站:
$.cookie('name', 'value', { expires: 7, path: '/' });
讀取cookie:
$.cookie('name'); // => "value"$.cookie('nothing'); // => undefined
讀取所有可用的餅干:
$.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
注意:在刪除cookie,你必須通過相同的路徑,域和安全選項,是用來設(shè)置cookie,除非你依靠默認的選項是。