cookie

function JSCookie() 

     this.GetCookie = function(key) 
     { 
         var value = document.cookie.match(new RegExp(";?"+key+"=([^;]*)","i")); 
         return unescape(value?value[1]:""); 
     }; 
     this.GetChild = function(cookiekey,childkey) 
     { 
         var child = this.GetCookie(cookiekey); 
        var getvalue = child.match(new RegExp("&?"+childkey+"=([^&;]*)","i")); 
         return unescape(getvalue?getvalue[1]:""); 
     }; 
     this.SetCookie = function(key,value,expire,path) 
     { 
         var cookie = ""; 
         if(key && value) cookie += key + "=" + escape(value) + ";"; 
         if(expire) cookie += "expires=" + expire.toGMTString() + ";"; 
         if(path) cookie += "path=" + path + ";"; 
         document.cookie = cookie; 
     }; 
     this.Expire = function(key) 
     { 
         expire_time = new Date(); 
         expire_time.setFullYear(expire_time.getFullYear() - 1); 
         var cookie = " " + key + "=e;expires=" + expire_time + ";" 
         document.cookie = cookie; 
     } 
}

var cookie = new JSCookie();

你可能感兴趣的:(cookie)