码迷,mamicode.com
首页 > Web开发 > 详细

jquery.cookie插件官方下载地址与使用方法

时间:2015-10-23 16:26:23      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

下载地址:https://github.com/carhartl/jquery-cookie

jquery.cookie使用方法:

创建 临时cookie:

$.cookie(‘name‘, ‘value‘);

创建有效时间期限为7天的 cookie:

$.cookie(‘name‘, ‘value‘, { expires: 7 });

创建有效期限为7天并带路径的 cookie:

$.cookie(‘name‘, ‘value‘, { expires: 7, path: ‘/‘ });

读取 cookie:

$.cookie(‘name‘); // => "value"
$.cookie(‘nothing‘); // => undefined

读取浏览器中所有的 cookies:

$.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

Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you‘re relying on the default options that is. 这段话自己翻译

 

jquery.cookie插件官方下载地址与使用方法

标签:

原文地址:http://www.cnblogs.com/attr/p/4904622.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!