You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

34 lines
982 B

/**
* Created by Administrator on 2017/2/23.
*/
var Cookie=new Object();
Cookie.setCookie=function(name, value, option){
var str=name+'='+escape(value);
if(option){
if(option.expireHours){
var d=new Date();
console.log("d:"+d);
d.setTime(d.getTime()+option.expireHours*3600*1000);
str+='; expires='+d;
}
if(option.path) str+='; path='+option.path;
//if(option.domain) str+='; domain='+option.domain;
//if(option.secure) str+='; true';
}
document.cookie=str;
};
Cookie.getCookie=function(name){
var arr = document.cookie.split('; ');
if(arr.length==0) return '';
for(var i=0; i <arr.length; i++){
tmp = arr[i].split('=');
if(tmp[0]==name) return unescape(tmp[1]);
}
return '';
};
Cookie.delCookie=function(name){
this.setCookie(name,'',{expireHours: -1, path: "/" });
};
//Cookie.setCookie('uidName',value,{expireHours: 5, path: "/" })