重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

jscookie操作的示例分析-创新互联

这篇文章主要介绍了js cookie操作的示例分析,具有一定借鉴价值,感兴趣的朋友可以参考下,希望大家阅读完这篇文章之后大有收获,下面让小编带着大家一起了解一下。

成都创新互联公司专注为客户提供全方位的互联网综合服务,包含不限于做网站、网站设计、万载网络推广、小程序制作、万载网络营销、万载企业策划、万载品牌公关、搜索引擎seo、人物专访、企业宣传片、企业代运营等,从售前售中售后,我们都将竭诚为您服务,您的肯定,是我们大的嘉奖;成都创新互联公司为所有大学生创业者提供万载建站搭建服务,24小时服务热线:028-86922220,官方网址:www.cdcxhl.com

cookieObj=function(){}
cookieObj.prototype.clearCookie = function() {
var now = new Date();
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
};

// [Cookie] Sets value in a cookie
cookieObj.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
document.cookie =
escape(cookieName) + '=' + escape(cookieValue)
+ (expires ? '; expires=' + expires.toGMTString() : '')
+ (path ? '; path=' + path : '')
+ (domain ? '; domain=' + domain : '')
+ (secure ? '; secure' : '');
};


// [Cookie] Gets a value from a cookie

cookieObj.prototype.getCookie = function(cookieName) {
var cookieValue = '';
var posName = document.cookie.indexOf(escape(cookieName) + '=');
if (posName != -1) {
var posValue = posName + (escape(cookieName) + '=').length;
var endPos = document.cookie.indexOf(';', posValue);
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
else cookieValue = unescape(document.cookie.substring(posValue));
}
return (cookieValue);
};

// [Cookie] Returns ids of open nodes as a string
dTree.prototype.updateCookie = function() {
var str = '';
//找到需要修改的key值key
this.setCookie('co' +key , str);
};

感谢你能够认真阅读完这篇文章,希望小编分享的“js cookie操作的示例分析”这篇文章对大家有帮助,同时也希望大家多多支持创新互联,关注创新互联-成都网站建设公司行业资讯频道,更多相关知识等着你来学习!


文章标题:jscookie操作的示例分析-创新互联
网页URL:http://cqcxhl.cn/article/degehh.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP