Javascript operations on cookie _ Get and modify code are improved with the previous method, and class methods are used.
The Code is as follows:
Function $ Cookie (){
Var a = arguments. callee;
Var B = a. _ cached;
If (a. _ cached) {return a. _ cached}
If (! (This instanceof a) {return new}
If (typeof a. _ cached = "undefined") {a. _ cached = this}
}
$ Cookie. prototype. get = function (e ){
Var a = document. cookie. split (/\ s *; \ s */);
Var d = new RegExp ("^ (\ s *" + e + "\ s * = )");
For (var B = 0; bif (d. test (a [B]) {return unescape (a [B]. substr (RegExp. $1. length ))}
}
Return null
};
$ Cookie. prototype. set = function (e, f, d, ){
Var B = "";
If (typeof d = "number") {B = "; expires =" + (new Date ()). getTime () + d x 1000*60*60*24 )). toGMTString ()}
If (typeof a = "undefined") {a = ""}
Document. cookie = e + "=" + escape (f) + B + "; path =/" + (? "; Domain =" + :"");
Return this
};
$ Cookie. prototype. remove = function (){
If (this. get ()! = Null) {this. set (a, "",-1 )}
Return this
};