cookieBAR

cookieBAR is a free & easy solution to the EU cookie law.

Why use cookieBAR?

There is a lot of mystery and fuss surrounding the EU cookie legislation, but it's essentially really simple. Cookies are files used to track site activity and most websites use them. Site owners need to make the use of cookies very obvious to visitors.

cookieBAR makes it simple and clear to visitors that cookies are in use and tells them how to adjust browser settings if they are concerned.

In my country, Italy, the cookie law is active since June 2015, and the fines are crazy. So if you still don't have it on your website you need to hurry up.

News
TL;DR

Just place this somewhere in your website and forget it:


<script type="text/javascript" src="//cdn.jsdelivr.net/cookie-bar/1/cookiebar-latest.min.js"></script>
            

Yes, it's THAT easy. You are not obliged to configure anything, you don't have to write any custom code... just add this script tag and forget it. By using the hosted version you will even have updates as soon as they show up. Instantaneously.

You may, however, want to add some functionalities, like choosing between a few themes, giving notice that you are using third party or tracking cookies, etc. To do so, please scroll this page down to the "configuration" section. Pick your desired options and I will give you the string you need to use in your website. Still easy, isn't it?

Oh, and if you are using Wordpress, there's a plugin for you too

How it works

cookieBAR is drop-in and forget. Written in pure vanilla javascript code, no jQuery or any other dependency needed. It shows up when needed and stay silent when not: If a website has some cookies or localStorage data set then the bar is shown, otherwhise nothing happens. This is configurable, anyway.

Once the user clicks 'Allow Cookies', cookieBAR will set a cookie for that domain with a name 'cookiebar' that will expire in 30 days. What this means is that the plugin will only show up once per domain (per month).

If a user decides to click "Disallow Cookies", cookieBAR will remove all the cookies and localStorage data (but it will show up again the first time a cookie is detected).

Important reading
Please note that in some countries the cookie law wants you to preventively block some cookies before they are set, in a opt-in choice for the user.
Doing so is a bit more technical than just having a banner like the cookieBAR, and there is not a unique solution for that. It depends on your website and its technology.
By using cookieBAR anyway, it is easy to detect if a user has accepted cookies by checking the presence of a cookie named "cookiebar".
That cookie can have two values: "CookieAllowed" or "CookieDisallowed".
These are some examples of this kind of check before loading a script:

In JavaScript:
<script type="text/javascript">
    cookieValue = document.cookie.match(/(;)?cookiebar=([^;]*);?/)[2];
    if (cookieValue == 'CookieAllowed') {
        // The user has allowed cookies, let's load our external services
    }
</script>
or PHP
<?php
if ($_COOKIE['cookiebar'] == "CookieAllowed") {
    // The user has allowed cookies, let's load our external services
}
?>
or Classic ASP VBScript
<%
If Request.Cookies("cookiebar") = "CookieAllowed" Then
    ' The user has allowed cookies, let's load our external services
End If
%>
If you have some snippets in other languages that could be useful to the users, please drop me a line.
How many languages are supported?

Currently, the supported languages for cookieBAR are:

The user language is automatically detected by the browser, but you can force a specific language by passing an optional parameter (see below).

If you want to help me with the translations, or add another language, please fork my Github repository and make a pull request with your additions.

Installation

You have two options if you decide to give cookieBAR a try:

  1. The stupid-easy (and probably better) one: use the hosted version (see TL;DR)
  2. Or, you can self-host it by yourself:
    1. Checkout the Github repository and place it somewhere in a folder within your website or your server. All of the files, including images and stylesheets, need to maintain it's relative structure - that is be in the same directory - for the plugin to work correctly.
    2. Put the code you have seen in TL;DR section, adjust the path with your own and put it somewhere on all relevant pages of your website.
If you need to add some configuration to it, please use the configurator below.
Configurator
<script type="text/javascript" src="//cdn.jsdelivr.net/cookie-bar/1/cookiebar-latest.min.js?"></script>

See a demo
Why did I write this?

Because I needed it. I got the idea from Studio NEC's permissionbar, which was beautiful, but I needed something more configurable, multilanguage and not dependent upon jQuery or any other javascript framework. So I forked the original project on GitHub and started to add what I needed, concluding with a pull-request whose code was completely rewritten. Sadly, the original project seems stopped since a couple of years and nobody has even probably seen my modifications. Several months later I decided to add even more things and to give this plugin a place to be, which is why it became cookieBAR.

Legal Reading

If you desire to know more about the cookie law, please read these links:

  1. Belgio: Commission de la protection de la vie privée ( Francese | Olandese )
  2. Czech Republic: Úřad pro ochranu osobních údajů
  3. France: Commission Nationale de l'Informatique et des Libertés
  4. Germany: Bundesbeauftragten für den Datenschutz und die Informationsfreiheit
  5. Italy: Garante per la protezione dei dati personali
  6. Luxembourg: Commission nationale pour la protection des données
  7. Netherlands: Autoriteit Consument en Markt
  8. Spain: Agencia de Protección de Datos
  9. UK: Information Commissioner's Office
Contributors (in order of appearance)

Code reviews, new functionalities, themes, languages... everything that can be useful for the users is very welcome. Plus, your name will be shown in this list :-)

See GitHub's list
Special thanks to the donors
Disclaimer

This program is free software. It comes without any warranty, to the extent permitted by applicable law. Use at your own risk and double check your local law before using it.

Need support? Please accept cookies and refresh the page :-)