我是 javascript 新手,我在编写 cookie 时遇到问题。这是我的代码
function writeCookie(name, value, days){
var cookie_expires;
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
cookie_expires = "; expires=" + date.toGMTString();
}
else {
cookie_expires = "";
}
document.cookie = name + "=" + value + cookie_expires;
}
然后如果我调用这个函数
function check(){
alert("all cookies"+document.cookie);
}
它什么也没给我。有人能帮我吗?