Skip to content

Instantly share code, notes, and snippets.

@BenSeward
Created September 15, 2016 11:00
Show Gist options
  • Save BenSeward/6213bfe00f453e2ac29e789efaca2641 to your computer and use it in GitHub Desktop.
Save BenSeward/6213bfe00f453e2ac29e789efaca2641 to your computer and use it in GitHub Desktop.
// Cookie banner that expires after 10 days
if (/(^|;)\s*visited=/.test(document.cookie)) {
$j('.cookie-banner').hide();
} else {
// 60 seconds to a minute, 60 minutes to an hour, 24 hours to a day, and 10 days.
document.cookie = "visited=true; max-age=" + 60 * 60 * 24 * 10;
$j('#accept-cookies').on('click', function() {
$j('.cookie-banner').hide();
});
}
@dblencowe
Copy link

dblencowe commented Sep 15, 2016

(function($){

      if (/(^|;)\s*visited=/.test(document.cookie)) {
               $j('.cookie-banner').hide();
      } else {
     // 60 seconds to a minute, 60 minutes to an hour, 24 hours to a day, and 10 days.
     document.cookie = "visited=true; max-age=" + 60 * 60 * 24 * 10;
     $j('#accept-cookies').on('click', function() {
          $j('.cookie-banner').hide();
     });
      }
 }(jQuery)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment