Setting cookies with javascript?

Discussion in 'JavaScript' started by mberman84, Dec 3, 2008.

  1. #1
    how do i set a cookie with javascript?

    this is what i have:

    var cookie_date = new Date ( );
    document.cookie = "clickcookie=clicked; expires=" + cookie_date.toGMTString();
    Code (markup):
    this doesnt seem to work. what am i doing wrong? i want to set a cookie called "clickcookie"...and i want it to expire in 30 days
     
    mberman84, Dec 3, 2008 IP
  2. pharmboy

    pharmboy Member

    Messages:
    30
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    43
    #2
    How do you know it's not working? Keep in mind that you can't see the cookie on the same page load.
     
    pharmboy, Dec 4, 2008 IP