Copy Code code 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 cookies are stored in Chinese information, there will be garbled, so the modification will solve the problem
Copy Code code as follows:
//cookie action functions
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;
}
The main is to change the unescape into a decodeuri.