(
)首先
介绍一下javascript操作cookie的基础
//去除空格回车
StringprototypeTrim = function()
{
return thisreplace(/(^\s*)|(\s*$)/g )
}
//设置Cookie
function setCookie(c_name c_valueexpiredays)
{
var exdate=new Date()
exdatesetDate(exdategetDate()+expiredays)
okie = c_name + = + escape(c_value) +
((expiredays==null) ? : ;expires=+exdatetoGMTString())
}
//按名字读取Cookie
function getCookie(c_name)
{
if (okielength>)
{
var m_car=okiesplit(;)
var value=;
for (i = ; i < m_carlength; i++)
{
if(c_nametoString()Trim()==((m_car[i]split(=))[])toString()Trim())
{
value = (m_car[i]split(=))[];
}
}
}
return value;
}