Copy codeThe Code is as follows: function Get_Cookie (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 Set_Cookie (name, value, expires, path, domain, secure ){
Expires = expires * 60*60*24*1000;
Var today = new Date ();
Var expires_date = new Date (today. getTime () + (expires ));
Var cookieString = name +... =... + Escape (value) +
(Expires )? ...; Expires =... + Expires_date.toGMTString ():......) +
(Path )? ...; Path =... + Path :......) +
(Domain )? ...; Domain =... + Domain :......) +
(Secure )? ...; Secure... :......);
Document. cookie = cookieString;
}
When Chinese information is stored in cookies, garbled characters will occur, which will solve the problem after modification.Copy codeThe Code is as follows: // cookie operation function
Function Get_Cookie (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 decodeURI (document. cookie. substring (len, end ));
}
Function Set_Cookie (name, value, expires, path, domain, secure ){
Expires = expires * 60*60*24*1000;
Var today = new Date ();
Var expires_date = new Date (today. getTime () + (expires ));
Var cookieString = name +... =... + Escape (value) +
(Expires )? ...; Expires =... + Expires_date.toGMTString ():......) +
(Path )? ...; Path =... + Path :......) +
(Domain )? ...; Domain =... + Domain :......) +
(Secure )? ...; Secure... :......);
Document. cookie = cookieString;
}
It mainly changed unescape to decodeURI.