简单封装一下js操作cookie的函数
代码语言:javascript复制//设置cookie
function setCookie(name,value,expireTime) {
var exp = new Date();
exp.setTime(exp.getTime() expireTime*1000);
document.cookie = name "=" escape (value) ";expires=" exp.toGMTString();
}
//读取cookie
function getCookie(name) {
var arr,reg=new RegExp("(^| )" name "=([^;]*)(;|$)");
if(arr=document.cookie.match(reg)){
return unescape(arr[2]);
}else{
return null;
}
}