Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    set cookie expiration

    I need to change the cookie expiration time to 1 year, but I'm confused about which line to change. I've checked several online tutorials, but I think they all assume I know too much. I think it may be this line, but can't find out what the numbers represent:
    var expires_date = new Date(todays_date.getTime() + (days * 86400000));
    Any help? Thanks!

    Obviously, this is just partial code:

    function Set_Cookie(name,value,expires,path,domain,secure) {
    document.cookie = name + "=" +escape(value) +
    ( (expires) ? ";expires=" + expires.toGMTString() : "") +
    ( (path) ? ";path=" + path : "") +
    ( (domain) ? ";domain=" + domain : "") +
    ( (secure) ? ";secure" : "");
    }

    function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
    ( (path) ? ";path=" + path : "") +
    ( (domain) ? ";domain=" + domain : "") +
    ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
    }

    var today = new Date();
    var zero_date = new Date(0,0,0);
    today.setTime(today.getTime() - zero_date.getTime());

    var todays_date = new
    Date(today.getYear(),today.getMonth(),today.getDate(),0,0,0);
    var expires_date = new Date(todays_date.getTime() + (days * 86400000));

  • #2
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    OK folks, I am trying. Maybe if I try to answer my own question, someone will help. Even a YES or NO will help.

    It's approximate of course, but what if I change this:
    var expires_date = new Date(todays_date.getTime() + (days * 86400000));

    to this:
    var expires_date = new Date(todays_date.getTime() + (days * 1096056000086));

    Would this be for about a year? What is this? milliseconds?

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,298
    Thanks
    203
    Thanked 2,561 Times in 2,539 Posts
    Yes, as you say, milliseconds.

    So make it (1000 * 60 * 60 *24 * 365) to get one year expiry.

  • #4
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks very much for the post, but you are giving me too much credit, too, I think. It doesn't make since, to me to replace:

    (days * 86400000)

    with

    (1000 * 60 * 60 *24 * 365)

    Will the script understand this? I don't think like a programmer, more like a mechanic - seems like I'm replacing 2 items with 5 and to me, the script won't understand this. Can you explain?

  • #5
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    isn't it that you just need to set the days variable to 365?

    var days = 365;
    var expires_date = new Date(todays_date.getTime() + (days * 86400000));

    the 86400000 is equivalent to 1 day in milliseconds. So if you multiply any number with it, you'd get that number of days in msec.

    look for the line that sets the days variable and change its value.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #6
    New to the CF scene
    Join Date
    Sep 2002
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Glenn,

    I had failed to copy that line, but there is such a line in the script. This makes sense to me - thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •