Loading... (0%)

Post published: Post last modified: 13 February 2015

New EU cookie law (e-Privacy Directive) – The law which applies to how you use cookies and similar technologies for storing information on a user’s equipment such as their computer or mobile device changed on 26 May 2011.

Source: ICO cookies guidance

Many people are not aware of it yet, but the law is already in effect in the UK. However The Information Commissioners’ Office (ICO), the UK regulator, gave everybody a one year ‘grace period’ before they start enforcing it.
That grace period will expire on May 26th 2012.
From that date, if you are not compliant or visibly working towards compliance, you run the risk of enforcement action, which can include a fine of up to half a million pounds for a serious breach.

Source: EU Cookie Law Explained – The Cookie Collective website

I made this simple JavaScript cookie warning to use it on my websites. I would be grateful if you give me a feedback on this script and I could improve it.

The script checks if cookies are allowed by browser and shows the cookie warning. If visitor agrees to accept cookies from the website, cookie will be saved for next 6 months and warning will disappear.

Some things to mention:

  • The script is not preventing the website from saving cookies on visitor’s computer as it is hard (if not impossible) to filter all cookies being produced by the website by just using single script (feedbacks on this are more than welcome ;))
  • The script is not redirecting to any other website if user didn’t agree to accept cookies. It might hurt SEO in my opinion (once again – please share your thoughts), although it’s easy to add this functionality to the script.
  • If JavaScript is disabled on browser then script won’t work.
  • You are free to modify and distribute this script.

Installation

  • Add this code between head tags:
    Cookies warning call
  • And this code where you want warning to appear:
    Cookies warning code
  • Download the script (warnCookies.js (version 0.9) or check the code (HTML, CSS and JavaScript) on GitHub) and upload it to your website. The code above will look for the script in root directory.
  • Add this CSS code to your stylesheet:
    Cookies warning CSS code

Screenshots

Cookie warning - Initial view
Cookie warning
Cookies disabled warning
Cookie warning (white)

Video tutorial (thanks to Fraser Mcculloch)









Related Images: