无为清净楼资源网 Design By www.qnjia.com
复制代码代码如下:jQuery.cookie = function(name, value, options) { if (typeof value != 'undefined') { // name and value given, set cookie options = options || {}; if (value === null) { value = ''; options.expires = -1; } var expires = ''; if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { var date; if (typeof options.expires == 'number') { date = new Date(); date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); } else { date = options.expires; } expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE } var path = options.path ? '; path=' + options.path : ''; var domain = options.domain ? '; domain=' + options.domain : ''; var secure = options.secure ? '; secure' : ''; document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); } else { // only name given, get cookie var cookieValue = null; if (document.cookie && document.cookie != '') { var cookies = document.cookie.split(';'); for (var i = 0; i < cookies.length; i++) { var cookie = jQuery.trim(cookies[i]); // Does this cookie string begin with the name we want? if (cookie.substring(0, name.length + 1) == (name + '=')) { cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); break; } } } return cookieValue; } }; function getcookie(name) { var cookie_start = document.cookie.indexOf(name); var cookie_end = document.cookie.indexOf(";", cookie_start); return cookie_start == -1 ? '' : unescape(document.cookie.substring(cookie_start + name.length + 1, (cookie_end > cookie_start ? cookie_end : document.cookie.length))); } function setcookie(cookieName, cookieValue, seconds, path, domain, secure) { var expires = new Date(); expires.setTime(expires.getTime() + seconds); document.cookie = escape(cookieName) + '=' + escape(cookieValue) + (expires ? '; expires=' + expires.toGMTString() : '') + (path ? '; path=' + path : '/') + (domain ? '; domain=' + domain : '') + (secure ? '; secure' : ''); }使用方法: 提供方便方法操作cookie :
复制代码代码如下:$.cookie('the_cookie'); // 获得cookie $.cookie('the_cookie', 'the_value'); // 设置cookie $.cookie('the_cookie', 'the_value', { expires: 7 }); //设置带时间的cookie 7天 $.cookie('the_cookie', '', { expires: -1 }); // 删除 $.cookie('the_cookie', null); // 删除 cookie 设置cookie的名值对,有效期,路径,域,安全 $.cookie(’name’, ‘value’, {expires: 7, path: ‘/’, domain: ‘jquery.com’, secure: true});
标签:
jquery,cookie
无为清净楼资源网 Design By www.qnjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
无为清净楼资源网 Design By www.qnjia.com
暂无评论...
更新日志
2024年06月14日
2024年06月14日
- 雷婷《雷婷出击》[WAV+CUE][550M]
- 杨钰莹《杨钰莹·精选集》[WAV+CUE][622M]
- 杜德伟.1994-未变过【滚石】【WAV+CUE】
- 林一峰.2013-Playlist【LYFEMusic】【FLAC分轨】
- 陈升.2015-是否,你还记得【新乐园】【WAV+CUE】
- 世界启元新手开荒阵容怎么组 萌新零氪组队攻略
- 世界启元一周可以抽多少次卡 一周抽卡次数介绍
- 世界启元乔瓦娜双攻队怎么玩 乔瓦娜双攻队阵容推荐
- 张学友《丝丝记忆情歌精选LPCD45》2007[FLAC+CUE]
- 张明敏《中国人中国心SACD精逊24bit[WAV]
- 群星-《唱给岁月的歌》CD1[WAV+CUE]
- 陈盈洁.1982-有人这么说(2016禾广复刻版)【乡城】【WAV+CUE】
- 刘锡明.1998-把你交给谁才不后悔【代言者】【WAV+CUE】
- 赵咏华.1993-求婚【全美唱片】【WAV+CUE】
- 《朴树3CD合集》[WAV/FLAC分轨][1.3G]