js操作cookie
直接看代码
<script language="javascript">
//写入cookie
function setCookie(name,value,expiresDays){
var d=new Date();
d.setTime(d.getTime()+expiresDays*24*60*60*1000);
document.cookie=name+'='+escape(value)+';'+(expiresDays==null?'':d.toGMTString());
}
//读取cookie
function getCookie(name){
str_cookie=document.cookie;
if(str_cookie.length>0){
start=str_cookie.indexOf(name+'=');
start+=name.length+1;
if(start!=-1){
end=str_cookie.indexOf(';',start);
if(end==-1){
end=str_cookie.length;
}
}
return unescape(str_cookie.substring(start,end));
}
return '';
}
</script>
</script>