-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcookie.js
More file actions
21 lines (21 loc) · 824 Bytes
/
Copy pathcookie.js
File metadata and controls
21 lines (21 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function cookieSave(name, value, second, domain, path) {
if (name) {
if (!second) second = 7 * 24 * 60;
if (!path) path = "/";
var date = new Date();
date.setTime(date.getTime() + (second * 1000));
var expires = "; expires=" + date.toGMTString();
if (domain) domain = "domain=" + domain + "; ";
document.cookie = name + "=" + value + expires + "; " + domain + "path=" + path;
}
}
function cookieGet(name) {
var name = name + "=";
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = cookies[i];
while (cookie.charAt(0) == ' ') cookie = cookie.substring(1, cookie.length);
if (cookie.indexOf(name) == 0) return cookie.substring(name.length, cookie.length);
}
return "";
}