Javascript读写Cookies时可使用的函数
function SetCookie(cookieName, cookieValue, nHours)
//cookies名、值和过期时间
{
var today = new Date();
var expire = new Date();
if (nHours == null || nHours == 0)
nHours = 1;
expire.setTime(today.getTime() + 1000 * 60 * 60 * 24 * nHours);
document.cookie = cookieName + "=" + escape(cookieValue) + ";expires=" +
expire.toGMTString();
}
function ReadCookie(cookieName)
//asp学习网 www.aspxuexi.com
{
var theCookie = "" + document.cookie;
var ind = theCookie.indexOf(cookieName);
if (ind == - 1 || cookieName == "")
return "";
var ind1 = theCookie.indexOf(';', ind);
if (ind1 == - 1)
ind1 = theCookie.length;
return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
}
本文主题Cookie