Dylan Thepiguy
Dylan Thepiguy

Reputation: 43

Cant set javascript cookie expiration date

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);

whats wrong here? it's like the code just stops at the + value + bit. chaning the number in the method calling line still results in a number change in the alert so i know it is setting something.

Upvotes: 0

Views: 540

Answers (1)

Nilesh Thakkar
Nilesh Thakkar

Reputation: 1459

alert wont give you expiration date, it will show only value. check your cookie with Firebug, it should be with proper expiration date.

Upvotes: 3

Related Questions