function setCookie(sName,sValue,expireHours) {
var cookieString = sName + "=" + escape(sValue)+";
path=/"
var date = new Date();
date.setTime(date.getTime + 24 * 3600 * 1000);
if (expireHours>0) {
cookieString = cookieString + "; expire=" + date.toGMTString() +";
path=/"
}
document.cookie = cookieString;
}
红色部份就是 cookie 的路径