/***js操作cookie,star***/
function addCookie(objName,objValue,objsec){//添加cookie
var str = objName + "=" + escape(objValue);
if(objsec > 0){//为0时不设定过期时间,浏览器关闭时cookie自动消失
var date = new Date();
var ms = objsec*1000;
date.setTime(date.getTime() + ms);
str += "; expires=" + date.toGMTString();
}
document.cookie = str;
//alert("添加cookie成功");
}
function getCookie(objName){//获取指定名称的cookie的值
var arrStr = document.cookie.split("; ");
for(var i = 0;i < arrStr.length;i ++){
var temp = arrStr[i].split("=");
if(temp[0] == objName) return unescape(temp[1]);
}
}
function delCookie(name){//为了删除指定名称的cookie,可以将其过期时间设定为一个过去的时间
var date = new Date();
date.setTime(date.getTime() - 10000);
document.cookie = name + "=a; expires=" + date.toGMTString();
}
//读取出来所有的cookie字筗串了
function allCookie(){//读取所有保存的cookie字符串
var str = document.cookie;
if(str == ""){
str = "没有保存任何cookie";
}
//alert(str);
}
//addCookie("admin","admin_value",60) //cookie名,cookie值,失效时间(秒)
//var getc = getCookie("admin") //获取cookie
//alert(getc);
//allCookie(); //获取全部cookie
//delCookie("admin"); //删除cicookie
//allCookie(); //获取全部cookie
/***js操作cookie,end***/