// --- 设置cookie
function setCookie(sName, sValue, expireHours) {
var cookieString = sName + "=" + escape(sValue);
//;判断是否设置过期时间
if (expireHours > 0) {
var date = new Date();
date.setTime(date.getTime + expireHours * 3600 * 1000);
cookieString = cookieString + "; expire=" + date.toGMTString();
}
document.cookie = cookieString;
}

//--- 获取cookie
function getCookie(sName) {
var aCookie = document.cookie.split("; ");
for (var j = 0; j < aCookie.length; j++) {
var aCrumb = aCookie[j].split("=");
if (escape(sName) == aCrumb[0])
return unescape(aCrumb[1]);
}
return null;
}