function getCookie(){
mycookie=document.cookie;
alert("cookie长度:"+mycookie.length+" 内容:"+mycookie);
return mycookie;
}function setCookie(){
if(getCookie().length==0){
document.cookie="this is the cookie that been saved manually!";
}
}以上JS函数在调用后,每次将浏览器关掉后,cookie输入还是空的,为什么呢?高手们帮忙看一下,不胜感激!
mycookie=document.cookie;
alert("cookie长度:"+mycookie.length+" 内容:"+mycookie);
return mycookie;
}function setCookie(){
if(getCookie().length==0){
document.cookie="this is the cookie that been saved manually!";
}
}以上JS函数在调用后,每次将浏览器关掉后,cookie输入还是空的,为什么呢?高手们帮忙看一下,不胜感激!
var str = objName + "=" + escape(objValue);
if(objHours > 0){//为0时不设定过期时间,浏览器关闭时cookie自动消失
var date = new Date();
var ms = objHours*3600*1000;
date.setTime(date.getTime() + ms);
str += "; expires=" + date.toGMTString();
}
document.cookie = str;
alert("添加cookie成功");
}