Cookies. Js code:
The function createCookie (name, value, days, path, domain, secure) {
If (days) {
Var date=new date ();
Date. SetTime (date. GetTime () + (days * 24 * 60 * 60 * 1000));
Var expires=date. ToUTCString ();
} the else var expires="";
CookieString=name + "=" + escape (value);
If (expires) cookieString +="; Expires="+ expires;
If (path) cookieString +="; Path="+ escape (path);
If (domain) cookieString +="; Domain="+ escape (domain);
If (secure) cookieString +="; Secure ";
Document. The cookie=cookieString;
}
The function getCookie (name) {
Var nameEquals=name + "=";
Var crumbs=document. Cookies. Split ('; ');
for (var i=0; i
If (crumb. IndexOf (nameEquals)==0) {
Return unescape (crumb. Substring (nameEquals. Length, crumb. Length));
}
}
return null;
}
The function deleteCookie (name) {
CreateCookie (name, "", 1);
}
Cookietest. HTML: