设置和获取cookie
function setCookie(name,value){
document.cookie = name + "=" + encodeURI(value);
}
function getCookie(name){
var str = document.cookie;
if(!str || str.indexOf(name + "=") < 0){
return null;
}
var cookies = str.split(";");
for(var i=0; i < cookies.length; i++){
var cookie = cookies[i];
if(cookie.indexOf(name + "=") == 0){
var value = cookie.substring(name.length + 1);
return decodeURI(value);
}
}
return null;
}