// 保存 Cookie
function setCookie(name, value, expireday) {
var exp = new Date();
exp.setTime(exp.getTime() + expireday * 24 * 60 * 60 * 1000); //设置cookie的期限
document.cookie = name + "=" + escape(value) + ";path=/;expires" + "=" + exp.toGMTString();//创建cookie
}
// 获取 Cookie
function getCookie ( name )var cookieStr = document.cookie;
if (cookieStr.length > 0) {
var cookieArr = cookieStr.split(";"); //将cookie信息转换成数组
for (var i = 0; i < cookieArr.length; i++) {
var cookieVal = cookieArr[i].split("="); //将每一组cookie(cookie名和值)也转换成数组
if (cookieVal[0] == name) {
return unescape(cookieVal[1]); //返回需要提取的cookie值
}
}
}
return "";
}
// 清除 Cookie
function delCookie ( name )var exp = new Date();
exp.setTime(exp.getTime() - 10000);
var cval = this.GetCookie(name);
if (cval != null) document.cookie = name + "=" + cval + ";path=/;expires=" + exp.toGMTString();
},