-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathcookie.js
44 lines (41 loc) · 1.38 KB
/
cookie.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
var phpcms_path = '/';
var cookie_pre = 'sYQDUGqqzH';
var cookie_domain = '';
var cookie_path = '/';
function getcookie(name) {
name = cookie_pre+name;
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while(i < clen) {
var j = i + alen;
if(document.cookie.substring(i, j) == arg) return getcookieval(j);
i = document.cookie.indexOf(" ", i) + 1;
if(i == 0) break;
}
return null;
}
function setcookie(name, value, days) {
name = cookie_pre+name;
var argc = setcookie.arguments.length;
var argv = setcookie.arguments;
var secure = (argc > 5) ? argv[5] : false;
var expire = new Date();
if(days==null || days==0) days=1;
expire.setTime(expire.getTime() + 3600000*24*days);
document.cookie = name + "=" + escape(value) + ("; path=" + cookie_path) + ((cookie_domain == '') ? "" : ("; domain=" + cookie_domain)) + ((secure == true) ? "; secure" : "") + ";expires="+expire.toGMTString();
}
function delcookie(name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = getcookie(name);
name = cookie_pre+name;
document.cookie = name+"="+cval+";expires="+exp.toGMTString();
}
function getcookieval(offset) {
var endstr = document.cookie.indexOf (";", offset);
if(endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}