0
function setMoney(value) {
    var myDate = new Date(2050, 9, 12);
    myDate.toUTCString();
    alert(document.cookie); //i get the old cookie as normal
    document.cookie = "money=" + value + ";expires=" + myDate + ";";
    alert(document.cookie); //i get money=987996 and i dont get the expiration date
}
setMoney(987996);

这里有什么问题?这就像代码只是停在 + 值 + 位。更改方法调用行中的数字仍然会导致警报中的数字更改,所以我知道它正在设置一些东西。

4

1 回答 1

3

警报不会给你到期日期,它只会显示价值。用 Firebug 检查你的 cookie,它应该有正确的到期日期。

于 2013-04-01T09:24:38.963 回答