/**
* Created by admin on 2016/3/30.
*/
function Setcookie (name,value,daytolive) {
var cookie = name + "=" +encodeuricomponent (value);
if (typeof daytolive = = = = "Number") {
Cookie + = "; max-age=" + (daytolive * 24 * 60 * 60);
}
Document.cookie = cookie;
}
function GetCookies () {
var cookies = {};
var all = Document.cookie;
if (all = = = "") {
return cookies;
}
var list = All.split (";");
for (Var i=0,len=list.length;i<len;i++) {
var cookie = list[i];
var p = cookie.indexof ("=");
var name = cookie.substring (0,p);
var value = decodeuricomponent (cookie.substring (p+1));
Cookies[name] = value;
}
return cookies;
}
Setcookie ("AAA", "111", 5);
Setcookie ("BBB", "222", 5);
var cookies = getcookies ();
for (var i in cookies) {
Attention!!! Firefox will default to two more private properties, but all start with "_"
if (Cookies.hasownproperty (i) && I.indexof ("_")! = 0) {
Document.cookie = i+ "=0;expires=" +new Date (0). toUTCString ();
Alert (i+ ":" + cookies[i]);
}
}
When you write the cache separately for IE, you can use the scope of the IE Userdata,ie UserData in the document that is in the same directory as the current document
Set up cookies and get cookies