2023-04-28 12:22:26 +08:00

18 lines
662 B
JavaScript

function setCookie(cname, cvalue, exdays) {
if (exdays === undefined) {
document.cookie = cname + "=" + cvalue + "; path=/" + "; document=" + document.domain;
} else {
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + "; " + expires + "; path=/" + "; document=" + document.domain;
}
}
function GetCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return unescape(decodeURI(arr[2]));
else
return null;
}