By law if you own a website and it uses cookies you need your visitors to consent to them. (Note you will need to inform the customer of the use of cookies etc. This can be done via a separate page on your website). You can add a not
The solution? A simple popup that appears on your website, this popup will let the visitors know if they consent to the use of cookies.
How do I do this? With JavaScript — If a visitor agrees to the use of cookies, JavaScript can store the “agreement” so the visitor doesn’t have to agree on every page they visit.
The script below will need to be edited for your own purpose:
<script> (function() { if (!localStorage.getItem('cookieconsent')) { document.body.innerHTML += '\ <div class="cookieconsent" style="position:fixed;padding:20px;left:0;bottom:0;background-color:#000;color:#FFF;text-align:center;width:100%;z-index:99999;">\ This site uses cookies. By continuing to use this website, you agree to their use. View More Information here\ <a href="#" style="color:#CCCCCC;">I Understand</a>\ </div>\ '; document.querySelector('.cookieconsent a').onclick = function(e) { e.preventDefault(); document.querySelector('.cookieconsent').style.display = 'none'; localStorage.setItem('cookieconsent', true); }; } })(); </script>
Remember to put this code at the end of your document just before the body close tag, this will ensure that it works correctly.