| var cookie= (function () { var getdatestring=function (offset) { var date=new date (); Date.settime (+date+offset*1000); return date.togmtstring (); }, Getcookies=function () { var cookie=document.cookie| | ', Subs=cookie.split (/;s?/), _subs,cks={}; for (Var i=0;i<subs.length,subs[i];i++) { _subs=subs[i].split (' = ') Cks[unescape (_subs[0])]=unescape (_subs.slice (1). Join (' = ')); } return cks; } return { Refresh:function () { This.cookies=getcookies (); return this; }, Has:function (key) { return this.cookies[key]!=null; }, Get:function (key) { return This.cookies[key]; }, Set:function (key,value,expire,path,domain,secure) { var myck=escape (key) + ' = ' +escape (value==null? ': value); if (!isnan (expire=parsefloat (expire)) myck+= '; expires= ' +getdatestring (expire); if (path) myck+= ';p ath= ' +path; if (domain&&domain!=location.hostname) myck+= ';d omain= ' +domain; if (secure) myck+= '; secure '; Document.cookie=myck; Return This.refresh (). has (key); }, Remove:function (Key,path,domain) { var paths=[], Domains=[], Arr,self=this; if (path) { Paths=[path]; }else{ Arr=location.pathname.match (/.*?/|. +$/G); This.each (Arr,function (i) { var A; Paths.push (A=arr.slice (0,i+1). Join (")"); if (/[^/]+/$/.test (a)) { Paths.push (A.slice (0,-1)); } if (/[^/]$/.test (a)) { Paths.push (A + '/'); } }); } if (domain) { Domains=[domain]; }else{ Arr=location.hostname.split ('. '); This.each (Arr,function (i) { Domains.push (Arr.slice (-i). Join ('. ')); }); Domains.push ('. ') +domains[0]); } This.each (Paths,function () { var path=this+ '; Self.each (Domains,function () { Self.set (Key, ', -1000,path,this+ '); }); }); Return!! path| |!! domain| |! This.has (key); }, Clear:function (Path,domain) { for (var key in this.cookies) { This.remove (Key,path,domain); } Return!! path| |!! domain| | function () { for (var key in this.cookies) { return false; } return true; }.call (this); }, Each:function (Arr,func) { var i=0,j=arr.length; for (; i<j;i++) { if (Func.call (arr[i],i) ===false) { Break } } } }.refresh (); })(); |