forked from hestiacp/hestiacp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookie.js
More file actions
45 lines (40 loc) · 1.15 KB
/
cookie.js
File metadata and controls
45 lines (40 loc) · 1.15 KB
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
45
var today = new Date();
var expiryyear = new Date(today.getTime() + 365 * 24 * 60 * 60 * 1000);
var expirymonth = new Date(today.getTime() + 30 * 24 * 60 * 60 * 1000);
var expiryday = new Date(today.getTime() + 24 * 60 * 60 * 1000);
function getCookie(name)
{
var reg= new RegExp("; "+name+";|; "+name+"=([^;]*)");
var matches=reg.exec('; '+document.cookie+';');
if (matches) return ((matches[1])?unescape(matches[1]):'');
return null;
}
function setCookie (name,value,expires,path,domain,secure)
{
document.cookie = name + "=" + escape (value) +
((expires) ? "; expires=" + expires.toGMTString() : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure" : "");
return getCookie(name)!=null?true:false;
}
function deleteCookie (name,path,domain)
{
if (getCookie(name)!=null)
{
document.cookie = name + "=" +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
"; expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
}
function cookieEnabled()
{
testCookieName="_testCookie_";
if (setCookie(testCookieName,1))
{
deleteCookie(testCookieName);
return true;
}
else return false;
}