function getCookie(cName) {
var cookieString = decodeURI(document.cookie);
var cookieArray = cookieString.split("; ");
for (var i = 0; i < cookieArray.length; i++) {
var cookieNum = cookieArray[i].split("=");
var cookieName = cookieNum[0];
var cookieValue = cookieNum[1];
if (cookieName == cName) {
return cookieNum;
}
}
return false;
}
function deleteCookie(key) {
var date = new Date();
date.setTime(date.getTime() - 1000);
setCookie(key, "", date.toGMTString(), "", "", "");
}
function setCookie(name, value, expires, path, domain, secure) {
document.cookie = name + "=" + encodeURI(value) +
((expires) ? "; expires=" + expires : "") +
((path) ? "; path=" + path : "") +
((domain) ? "; domain=" + domain : "") +
((secure) ? "; secure=" + secure : "");
}
网友评论