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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Gaborone, Botswana
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts

    cookie expiration...

    hi,

    i am using the following script to write a cookie:

    <html>
    <head>

    <SCRIPT LANGUAGE="JavaScript"><!--
    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" : "");
    }
    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() + (52 * 7 * 86400000)); // 52 weeks

    var name = 'cookied';
    var value = '52477001';

    Set_Cookie(name,value,expires_date);
    //--></SCRIPT>


    </head>

    </html>


    Now, if i want the cookie to expire after, say, 15 minutes, what should i edit? is it the 52*7*86400000?

    thanks in advance,

    d52477001

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yes, the 52*7*86400000 is setting the cookie to expire in one year (which is 52 weeks times 7 days per week times 86400000 milliseconds per day). Fiveteen minutes would be 15*60*1000 or fiveteen minutes times 60 seconds per minute times 1000 milliseconds per second.
    Check out the Forum Search. It's the short path to getting great results from this forum.

  • #3
    New to the CF scene
    Join Date
    Jun 2003
    Location
    Gaborone, Botswana
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ah right, it's in milliseconds....

    thanks!

    d52477001


  •  

    Posting Permissions

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