As you might have noticed to be compliant with new EU law about cookies (oh those evil dreaded virus spreading cookies LOL). I have created two generic EU Cookie / Privacy JavaScript Scripts that can be added to any site in a global footer which makes the site comply with the EU's new law on website privacy and cookies.
The new version accommodates the last minute change in EU law which allows you to show a message about your cookie policy and treat the users continued use of the site as an "opt in" with a button to set a cookie so the message isn't shown again. Funny how we have to use cookies to know whether to use them or not!
The first version make use of jQuery (easily fixed if you need to) and sets a panel at the top of the screen which slides in and out and offers the user a choice to hide the message in future. You can read about this version on my blog posting about EU Cookie compliance here. You can also view an HTML test page with the code working here or just download the JavaScript source code from here.. As you can see it's simple and sweet and most UK sites are using a version of it at the moment to comply with the EU law.
The second version is a lightbox that will appear if cookies have not been agreed to and is a more forcful approach as the user HAS to read it and either confirm they are happy or be taken away from the site. This EU Cookie Compliance JavaScript can be downloaded from here and added to any site in the same way as the first (e.g in the footer).
The parameters at the top of the script that display the message and the wording for the buttons are all customisable and you can modify the code to pass in different variables as you see fit.
The script also handles browsers where the user has totally disabled cookies either through a toolbar like the Web Developer Toolbar or through the browser itself. If the user has done this then the message won't even appear but if they decide to re-enable cookies halfway through the visit then the script will detect their availability and show the message as soon as possible.
If the user decides they don't want to use cookies and make use of the site then they are taken away to another customisable URL (see the
source code) otherwise they have
a cookie set called "EUCookie" for 365 days and everytime they re-visit the site it rolls over for another 365 days unless they have cleared the cookie from their browser. This other URL could be a
"cookie free" version of your site or another site altogether. I have defaulted it to
blog.strictly-software.com for now.
As most non techie people don't know what cookies are I have tried explaining in my message what cookies are and how they don't lead to viruses etc. Feel free to use
the code on your own site (with credit of course) and change the message as you feel fit.
To get the code working on your site just add in a <script src="//www.mysite.com/scripts/EUCookieCode.js" ><script> reference to the scripts location at the bottom of your site before the closing <body> tag and the code will run automatically as it's wrapped in a self calling function and if you are using the first version make sure to load in jQuery or replace the sliding animation with your own code.
You can download the slider version of the EU Cookie Privacy Compliance code here.
You can download the lightbox version of the EU Cookie Privacy Compliance code here.