title: Setting cookie to expire after one day
body: <p>I have used this code I got from git. Its basically set up to set a cookie to display a popup on the first visit to the site only. However, I want it to only set it for 24 hours. So if someone comes back to the site in a day or two it will show again. </p>
  
  <pre><code>(function ($) {
  
      'use strict';
  
      $.fn.firstVisitPopup = function (settings) {
  
          var $body = $('body');
          var $dialog = $(this);
          var $blackout;
          var setCookie = function (name, value) {
              var date = new Date(),
                  expires = 'expires=';
              date.setTime(date.getTime() + 31536000000);
              expires += date.toGMTString();
              document.cookie = name + '=' + value + '; ' + expires + '; path=/';
          }
          var getCookie = function (name) {
              var allCookies = document.cookie.split(';'),
                  cookieCounter = 0,
                  currentCookie = '';
              for (cookieCounter = 0; cookieCounter &lt; allCookies.length; cookieCounter++) {
                  currentCookie = allCookies[cookieCounter];
                  while (currentCookie.charAt(0) === ' ') {
                      currentCookie = currentCookie.substring(1, currentCookie.length);
                  }
                  if (currentCookie.indexOf(name + '=') === 0) {
                      return currentCookie.substring(name.length + 1, currentCookie.length);
                  }
              }
              return false;
          }
          var showMessage = function () {
              $blackout.show();
              $dialog.show();
          }
          var hideMessage = function () {
              $blackout.hide();
              $dialog.hide();
              setCookie('fvpp' + settings.cookieName, 'true');
          }
  
          $body.append('&lt;div id="fvpp-blackout"&gt;&lt;/div&gt;');
          $dialog.append('&lt;a id="fvpp-close"&gt;&amp;#10006;&lt;/a&gt;');
          $blackout = $('#fvpp-blackout');
  
          if (getCookie('fvpp' + settings.cookieName)) {
              hideMessage();
          } else {
              showMessage();
          }
  
          $(settings.showAgainSelector).on('click', showMessage);
          $body.on('click', '#fvpp-blackout, #fvpp-close', hideMessage);
  
      };
  
  })(jQuery);
  </code></pre>