1 //设置COOKIE值
2 function setCookie(sName,sValue,oExpires,sPath,sDomain,bSecure)
3 {
4 var sCookie = sName + "=" + encodeURIComponent(sValue);
5
6 if(oExpires) { sCookie += "; expires=" + oExpires.toString(); }
7
8 if(sPath) { sCookie += "; path=" + sPath; }
9
10 if(sDomain) { sCookie += "; domain=" + sDomain; }
11
12 if(bSecure) { sCookie += "; secure"; }
13
14 document.cookie = sCookie;
15 }
16
17 //获取COOKIE值
18 function getCookie(sName)
19 {
20 var sRE = "(?:; )?" + sName + "=([^;]*);?";
21 var oRE = new RegExp(sRE);
22
23 if(oRE.test(document.cookie)) { return decodeURIComponent(RegExp["$1"]); }
24 else { return null; }
25 }
26
27 //删除COOKIE值
28 function deleteCookie(sName,sPath,sDomain)
29 {
30 setCookie(sName,"",new Date(0),sPath,sDomain);
31 }