-
Notifications
You must be signed in to change notification settings - Fork 0
/
cookie
21 lines (21 loc) · 795 Bytes
/
cookie
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var QQ = {};
QQ.Cookie={
set:function(name,value,expires,path,domain){
if(typeof expires=="undefined"){
expires=new Date(new Date().getTime()+3600*1000);
}
document.cookie=name+"="+escape(value)+((expires)?"; expires="+expires.toGMTString():"")+((path)?"; path="+path:"; path=/")+((domain)?";domain="+domain:"");
},
get:function(name){
var arr=document.cookie.match(new RegExp("(^| )"+name+"=([^;]*)(;|$)"));
if(arr!=null){
return unescape(arr[2]);
}
return null;
},
clear:function(name,path,domain){
if(this.get(name)){
document.cookie=name+"="+((path)?"; path="+path:"; path=/")+((domain)?"; domain="+domain:"")+";expires=Fri, 02-Jan-1970 00:00:00 GMT";
}
}
};