Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6810093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:09:52+00:00 2026-05-26T20:09:52+00:00

I am using a cookie on my site to display colorbox one time on

  • 0

I am using a cookie on my site to display colorbox one time on page load then after that the user has the option to manually load the colorbox each time. But what I do not understand is how you set the expiration date for the cookie. I got the needed code from another question here on SO and it would help if someone could explain to me what is what here.

var $j = jQuery.noConflict();

$j(document).ready(function(){

   if (document.cookie.indexOf('visited=true') == -1) 
   {
      var fifteenDays = 1000*60*60*24*15;
      var expires = new Date((new Date()).valueOf() + fifteenDays);
      document.cookie = "visited=true;expires=" + expires.toUTCString();
      $j.colorbox({ inline:true, href:"#gallery-nav-instruct"});
   }

});

I would assume this means the cookie expires in 15 days. How would I change this to longer? Say 30 or 60 days?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:09:52+00:00Added an answer on May 26, 2026 at 8:09 pm

    The key thing to note here is

    var fifteenDays = 1000*60*60*24*15;
    

    15 days each having 24 hours, each having 60 minutes, each having 60 seconds.

    The last factor is 1000. so fitteenday variable is holding the number of milliseconds in 15 days.

    var expires = new Date((new Date()).valueOf() + fifteenDays);
    

    This statement implies the expiration date of the cookie is whatever current date is plus 15 days.

    So in your case when you want expiration of 15 or 30 days, you just need to replace 15 with however days you have in mind

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a cookie that is on every page of my site. It works
I can get an Authentication cookie from a SharePoint site that is not using
I'm using set_cookie() on a site. After adding some functionality, I'm getting Warning: Cannot
I am trying to fetch a page with Python, and using the cookie jar.
i'm using the jquery cookie plugin. Everything works fine except the fact that I
While using cURL with some site, I noticed that some files that I requested
I have a site that i am using session variables. up until last Wednesday
I've read online (on Google's own recommendations for site optimisation techniques) that using cookies
I have a page that displays data which is read from a cookie. The
We're using a cookie for some non-sensitive convenience data about our site visitors. We

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.