//获得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=" 还可以设置作用域
}