1 var YCookie=new function(){ 2 this.deleteAll=function(){ 3 var cookies = document.cookie.split(";"); 4 for (var i = 0; i < cookies.length; i++) { 5 this.del(cookies[i].split("=")[0]); 6 } 7 }; 8 this.clear=this.deleteAll=this.delAll; 9 this.del=function(name){ 10 document.cookie = name + "=;expires=Thu, 01 Jan 1970 00:00:00 GMT"; 11 }; 12 this['delete']=this.del; 13 this.set=function(name,value,exdays){ 14 var exdate=new Date(); 15 exdate.setDate(exdate.getDate() + exdays); 16 var c_value=escape(objToStr(value,0,20)) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString()); 17 document.cookie=name + "=" + c_value; 18 }; 19 this.tmpcv=null; 20 this.get=function(name,value,exdays){ 21 this.tmpcv = document.cookie; 22 var c_start = this.tmpcv.indexOf(" " + name + "="); 23 if (c_start == -1){ c_start = this.tmpcv.indexOf(name + "="); } 24 if (c_start == -1){ this.tmpcv = null; 25 }else{ 26 c_start = this.tmpcv.indexOf("=", c_start) + 1; 27 var c_end = this.tmpcv.indexOf(";", c_start); 28 if (c_end == -1){ c_end = this.tmpcv.length; } 29 this.tmpcv = unescape(this.tmpcv.substring(c_start,c_end)); 30 eval("this.tmpcv="+this.tmpcv+";"); 31 } 32 return this.tmpcv; 33 }; 34 }(); 35