//获取cookie
function getCookie(key,value){
var c = document.cookie;
var str = key + '=' + value;
var re = new RegExp('(^|\\s)'+str+';?($|\\s)');
return re.test(c);
}
//设置cookie
function setCookie(key,val,time){
time = time?time:0;
var data = new Date();
data.setDate(data.getDate()+time);
document.cookie = key+'='+val+';expires='+(time?data:0);
}
//删除cookie
function removeCookie(key,value){
setCookie(key,value,-1);
}
转载于:https://www.cnblogs.com/week-1/p/6576324.html