// 添加cookie
function addCookie(key,value,days) {
var now = new Date();
now.setDate(now.getDate() + days);
document.cookie = key+"="+value+"; expires="+now;
}
// 获取cookie
function getCookie(key) {
var str = document.cookie;
if(!str) return null;
var reg1 = new RegExp(key+"=([^;]+)$");
var reg2 = new RegExp(key+"=([^;]+);");
if(reg1.test(str)) {
return str.match(reg1)[1];
} else {
return str.match(reg2)[1];
}
}