//获取cookie
var _getCookie=function (name) {
if (document.cookie.length > 0) {
c_start = document.cookie.indexOf(name + "=")
if (c_start != -1) {
c_start = c_start + name.length + 1
c_end = document.cookie.indexOf(";", c_start)
if (c_end == -1) c_end = document.cookie.length
return unescape(document.cookie.substring(c_start, c_end))
}
}
return "";
};
//删除cookie
var _delCookie=function (name) {
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = _getCookie(name);
if (cval != null)
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + "; path=/";
};
//设置cookie方法
var _setCookie=function (key,val,time) {
if (time == null)
time = 1;
var date = new Date(); //获取当前时间
var expiresDays = time; //将date设置为n天以后的时间
date.setTime(date.getTime() + expiresDays * 24 * 3600 * 1000); //格式化为cookie识别的时间
document.cookie=key + "=" + val +";expires="+date.toGMTString() + "; path=/"; //设置cookie
};