Create a new cookie. When hours is an empty string, the lifetime of the cookie ends with the browser session.
Hours is the number 0 o'clock, a failed cookie is created that overwrites the already established cookie with the same path (if the cookie exists).
function Setcookie (name,value,hours,path) {var name = Escape (name);
var value = Escape (value);
var expires = new Date ();
Expires.settime (Expires.gettime () + hours*3600000);
Path = Path = ""? "": ";p ath=" + path; _expires = (typeof hours) = = "string"?
"": "; expires=" + expires.toutcstring ();
Document.cookie = name + "=" + value + _expires + path;
//Get the cookie value function Getcookievalue (name) {//Read cookie property, which returns all of the document's cookie var allcookies = Document.cookie;
Finds the start position of the cookie named name = = "=";
var pos = allcookies.indexof (name); If a cookie with that name is found, it is extracted and used with its value if (POS!=-1) {//If the POS value of-1 indicates that the search for "version=" is missing var start = pos + name.length; The position where the cookie value starts var end = Allcookies.indexof (";", start); Search for the first ";" from where the cookie value starts.
Position, that is, the end of the cookie value if (end = = 1) end = Allcookies.length; If the end value is-1, only one cookie in the cookie list is var value = allcookies.substring (start,end); Extract the value of the cookie return unescape (value); Decode it} else return "";
Search failed, return empty string}//Delete cookie function Deletecookie (name,path) {var name = Escape (name);
var expires = new Date (0);
Path = Path = ""? "": ";p ath=" + path;
Document.cookie = name + "=" + "expires=" + expires.toutcstring () + path;
}