Jquery. Cookie = function (name, value, options ){
If (typeof value! = 'Undefined '){
Options = options | {};
If (value = NULL ){
Value = '';
Options = $. Extend ({}, options );
Options. expires =-1;
}
VaR expires = '';
If (options. expires & (typeof options. expires = 'number' | options. expires. toutcstring )){
VaR date;
If (typeof options. expires = 'number '){
Date = new date ();
Date. settime (date. gettime () + (options. expires * 24x60*60*1000 ));
} Else {
Date = options. expires;
}
Expires = '; expires =' + date. toutcstring ();
}
VaR Path = options. Path? '; Path =' + (options. Path ):'';
VaR domain = options. domain? '; Domain =' + (options. domain ):'';
VaR secure = options. secure? '; Secure ':'';
Document. Cookie = [name, '=', encodeuricomponent (value), expires, path, domain, secure]. Join ('');
} Else {
VaR cookievalue = NULL;
If (document. Cookie & document. Cookie! = ''){
VaR cookies = Document. Cookie. Split (';');
For (VAR I = 0; I <cookies. length; I ++ ){
VaR cookie = jquery. Trim (Cookies [I]);
If (cookie. substring (0, name. Length + 1) = (name + '= ')){
Cookievalue = decodeuricomponent (cookie. substring (name. Length + 1 ));
Break;
}
}
}
Return cookievalue;
}
};
call method! $ (document ). ready (function () {
$ ('# wcookies '). click (function () {
$. cookie ('name', 'test', {expires: 7});
});
$ ('# rcookies '). click (function () {
var test = $. cookie ('name');
alert (TEST);
});
$ ('# dcookies '). click (function () {
$. cookie ('name', null);
});