// 设置cookie(储存数据) function setcookie(name,value,expired,path,domain){ var now=new Date(); if(name==null){ throw "Cookie Name Must not be Null"; }else if (value==null){ throw "Cookie Value Must not be Null"; }else if(expired==null){ expired=0; } if(path==null){ path="/"; } if(domain==null){ domain=window.location.host; } now.setTime(now.getTime()+expired*1000); document.cookie=name+"="+escape(value)+";expires="+now.toGMTString()+";path="+path+";domain="+domain; }
// 读取cookie(读取数据) function getcookie(name){ var allcookie=document.cookie; thiscookie=allcookie.match(name+"=[^\\s]*"); mycookie=thiscookie[0].split("="); a=mycookie[1].substring(0,mycookie[1].length-1); return unescape(a); }