Skip to content

Instantly share code, notes, and snippets.

@bavington
Last active May 17, 2022 06:22
Show Gist options
  • Save bavington/6727776 to your computer and use it in GitHub Desktop.
Save bavington/6727776 to your computer and use it in GitHub Desktop.
Simple EU Cookie Law Banner JavaScript
@bluefirex
Copy link

bluefirex commented Dec 4, 2019

For future Googlers: This script is NOT legally valid anymore.
https://www.reuters.com/article/us-eu-court-cookies/internet-users-must-actively-consent-to-use-of-cookies-eu-court-rules-idUSKBN1WG3NF

[...] cookie consent must be specific and explicit and that clicking a button to participate in a game or browsing a website, and through that allowing cookies, was not enough.

@cgowez
Copy link

cgowez commented Sep 2, 2020

Thanks @bavington and @timgerhard, this is simple and useful. I did a minor change as some people said, refreshing the page without closing the banner, it will just disappear, when createCookie function is called I create the cookie with a different value let's say "off" so if you reload the page function checkCookie looks for specific value, since it is different it will display the banner again when the user clicks to close the banner function removeMe is invoked so there I update the cookie value to "on".

Thanks.

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