设置cookie:
var setcookie = function (name,value,day){
if(day !== 0 ){/当前时间等于0时,不设置expires属性,随浏览器关闭
var expires = day*24*60*60*1000;
var date = new Date(+new Date()+expires)
document.cookie = name + '=' +escape(value) + ';expires=' + date.toUTCString();
}else{document.cookie = name + '=' + escape(value);}
}
获取cookie:
var getCookie = function (name) {
var arr;
var reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if(arr = document.cookie.match(reg)){
return unescape(arr[2])
}else{ return null ;}
}
删除cookie:
var delCookie = function (name){
setCookie(name,‘ ’,-1)
}
——————————————————————————————————