var cookie = {
setCookie(c_name,c_value,expireTime){
let expDate = new Date();
expDate.setDate(expDate.getDate() + expireTime);
document.cookie = c_name + '=' + c_value + ((expireTime ==?) "" : ";expires=" + expDate.toGMTString());
},
getCookie(c_name){
let reg = new RepExp("(^| )" + c_name + "([^;]*)(;|$)");
let atri = null;
if( atri = document.cookie.match(reg)){
return (atri[2]);
}else{
return null;
}
},
delCookie(c_name){
let c_value = cookie.getCookie(c_name);
if(c_value !=null){
document.cookie = name + '=; expires=Thu, 01 Jan 1970 00:00:01 GMT;';
}
},
}
js cookie设置, 获取, 删除
最新推荐文章于 2023-09-08 14:33:31 发布