Caution: this post was published in 2018 and may contain information, techniques or code examples that are no longer current. Please double-check official documentation and modern best practices before using anything from this article.

This post is from 2019, it may be out-of-date. For a better solution try: Cookie Script for GDPR

Simple no-nonsense JavaScript and CSS cookie pop-up notification for legacy websites. Required jQuery.

Reusable cookie pop-up

<!DOCTYPE html>
<html>
<body>
<!-- JavaScript and CSS framework independent cookie pop-up notification for legacy websites. -->

<div id="privacy-pop-up" style="display:none; position:fixed; z-index:9999; bottom:0; left:0; right:0; background:#dc143c; color:#fff; margin:1em; padding:0.5em; text-align:center;  ">
  <strong>Important information regarding cookies</strong><br>
  By using this website, you consent to the use of cookies in accordance with our
  <a href="/privacy-policy" style="text-decoration: underline; color:#fff">Privacy Policy</a>.<br>
  <a  id="exit-popup" style="background:#fff; color:#000; padding:0.25em 0.5em; margin:0.5em; cursor:pointer; font-weight:bold; font-size:90%;  ">
  Understood, hide this message</a>
</div>

<script>
    jQuery(document).ready(function() {
        if(localStorage.getItem('pc234978') != '923847'){
            jQuery("#privacy-pop-up").delay(1).fadeIn(1000);
            localStorage.setItem('pc234978','923847');
        } else { console.log("2 " + "returning"); }
        jQuery('#exit-popup').click(function(e) // You are clicking the close button
        {
            jQuery('#privacy-pop-up').fadeOut(1000); // Now the pop up is hiden.
        });
    });
</script>

</body>
</html>