标签:time function for expires name domain tco cti dom
//获得cookie
function GetCookie(sName)
{
var aCookie = document.cookie.split("; ");
for (var i=0; i < aCookie.length; i++)
{
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
return unescape(aCrumb[1]);
}
return null;
}
//设置带时效的cookie
function SetCookie(name, value) {
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + 7*24*3600*1000);//时效7天
document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString()+";path=/"; //+";domain=" 还可以设置作用域
}
标签:time function for expires name domain tco cti dom
原文地址:http://www.cnblogs.com/mxy666/p/6055090.html