8.7w+
社区成员
function cookie()
{
this.write = function (name, value, expireHours)
{
var cookieString = name + "=" + escape(value);
if(expireDays)
{
var date = new Date();
date.setTime(date.getTime() + expireHours * 3600 * 1000);
cookieString += "; expires=" + date.toGMTString();
}
document.cookie = cookieString;
},
this.read = function (name)
{
var returnValue = "";
var cookieArray = document.cookie.split("; ");
for(var i = 0; i < cookieArray.length; i++)
{
var arr = cookieArray[i].split("=");
if(arr[0] == name)
{
returnValue = unescape(arr[1]);
}
}
return returnValue;
}
}
cookie c = new cookie();
c.write(...);
var value = c.read(...);