www.webdeveloper.com
Results 1 to 3 of 3

Thread: var expiredays = "1"; Change to 1 hour instead?

Hybrid View

  1. #1
    Join Date
    Nov 2008
    Location
    Niagara Falls, Canada
    Posts
    356

    var expiredays = "1"; Change to 1 hour instead?

    In my JS code, I have this
    Code:
    var expiredays = "1";
    which sets a "cookie" to expire in 1 day. However, I want it to expire in 1 hour instead. Is there a way to do that?

    Thanks

  2. #2
    Join Date
    Nov 2008
    Location
    Niagara Falls, Canada
    Posts
    356
    Here is a better look at more of the relevant code:
    Code:
    function BookMark() {
     
    $('#BookmarkImg').animate({ "top": "-81px" }, 1000);
     
    baseCookieName = "rwbookmark";
     
    var exdate = new Date();
     
    var expiredays = "1";
     
    exdate.setDate(exdate.getDate() + expiredays);
     
    //use of arbritary stop point so no endless loop occurs
     
    for (var i = 0; i < 10000; i++) {
     
    var curName = baseCookieName + i;
     
    if (document.cookie.indexOf(curName) < 0) {
     
    document.cookie = curName + "=" + escape(window.location.href) + "[#]contentid=" + document.getElementById("inputContentID").value + "[#]title=" + GetPageTitle() + ";expires=" + exdate.toGMTString() + ";path=/;domain=domain.ca;";
     
    break;
     
    }

  3. #3
    Join Date
    Nov 2010
    Posts
    1,085
    without looking at it too much, the first thing I would try is:

    Code:
    var expirehours = "1";
     
    exdate.setDate(exdate.getHours() + expirehours);
    or something like that

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles