JavascriptCookie: The function code for reading, writing, and deleting cookies. For more information, see.
The Code is as follows:
Function getCookie (name)
{
Var start = document. cookie. indexOf (name + "= ");
Var len = start + name. length + 1;
If ((! Start) & (name! = Document. cookie. substring (0, name. length ))){
Return null;
}
If (start =-1) return null;
Var end = document. cookie. indexOf (';', len );
If (end =-1) end = document. cookie. length;
Return unescape (document. cookie. substring (len, end ));
}
//----------------------------------------------------//
Function setCookie (name, value, expires, path, domain, secure ){
Var today = new Date ();
Today. setTime (today. getTime ());
If (expires ){
Expires = expires * 1000*60*60*24;
}
Var expires_date = new Date (today. getTime () + (expires ));
Document. cookie = name + '=' + escape (value) +
(Expires )? '; Expires =' + expires_date.toGMTString (): '') + // expires. toGMTString ()
(Path )? '; Path =' + path: '') +
(Domain )? '; Domain =' + domain: '') +
(Secure )? '; Secure ':'');
}
//----------------------------------------------------//
Function deleteCookie (name, path, domain)
{
If (getCookie (name) document. cookie = name + '=' +
(Path )? '; Path =' + path: '') +
(Domain )? '; Domain =' + domain: '') +
'; Expires = Thu, 01-Jan-1970 00:00:01 gmt ';
}