首页 > 代码库 > cookie
cookie
function addCookie(mess,fivFree){
var Days=fivFree?15:1; //15天免登录
var exp=new Date();
exp.setTime(exp.getTime()+Days*24*60*60*1000);
document.cookie="token="+escape(mess)+";expires="+exp.toGMTString();
}
function delCookie(){
var exp=new Date();
exp.setTime(exp.getTime()-1);
var cval=getCookie("token");
if(cval!=null)
document.cookie="token="+cval+";expires="+exp.toGMTString();
}
function checkOld(data){
if(window.location.pathname=="/"){
if(!localStorage.getItem(data.data.mobile) && data.data.nick_name.match(/用户[0-9]{4}/)){
myConfirm("老用户请前往<span style=‘color:#ff5454;‘>[个人设置]</span>面板将信息补充完整,否则会对该功能使用造成一些影响",false,false,"前往",function(){
window.location.href="http://www.mamicode.com/userCenter?type=user";
});
localStorage.setItem(data.data.mobile,true);
}
}
}
function getCookie(name){
var arr,reg=new RegExp("(^|)"+name+"=([^;]*)(;|$)");
if(arr=document.cookie.match(reg))
return unescape(arr[2]);
else
return null;
}
cookie