UK & European Cookie Law Solution (Free Script)
Andy Schaff Jun 1 2011
A European cookie law that regulates the use of web browser cookies is now in effect in the UK. That cookie law is based on guidelines set by the European Union. In a nutshell, the law states that websites must get a user’s consent before storing cookies on their device (computer, mobile phone, iPad, etc). There’s a lot of confusion around the UK law, and the EU regulation:
- Does it apply to companies based outside the UK?
- It allows an exception for cookies that are ‘strictly necessary’. What counts? Shopping cart cookies do. But what about analytics? Login cookies?
There are no clear answers. The UK did promise to phase in enforcement over time. But if this law succeeds, more cookie regulation is on the horizon. If you own a web site, chances are, you’re placing cookies on visitor’s computers, and you need to comply.
So, we’ve built a simple way to comply with the regulation and its free. Read on to get the code and implement it on your own site.
Note: You use this code at your own risk. We’re not responsible if the UK finds you in violation of their law.
Update (8/7/12): We have learned that about 1 in 50 requests to GeoBytes.com may redirect to an undesired page. This is the result of using the free version of the geolocation service by GeoBytes. I never encountered this in my testing, but I never did any stress testing. To avoid this, you will have to sign up for the GeoBytes service, which seems to be somewhere in the range of $10 (USD) per 10,000 geolocation requests.
The Script: cookieConsent.js
To initiate the script, after page load, put this code snippet just above the end body tag on every page that writes cookies:
Static Cookie Consent HTML page: cookie-consent.htm
You must talk to your attorney before you set up this page. Portent is not a law firm, and we’re not giving legal advice.
For more information regarding the EU Cookie Laws and suggested updates, see the following:
For an interactive demo, please visit cookieconsent.portent.com.
The script will require any user located in Europe or North America (for demo purposes) to consent to cookies being written on the site. If you’re having troubles implementing the script, try viewing the source code of the demo. Also, take a look at the comments below for additional assistance!
Highly motivated senior developer with 10 years of experience who will take on any technology thrown at him. A proponent of well-formed and documented code, MVC technologies, and high attention to detail, Andy is the leader of development at Portent. Read More
- Do You Use Data To Improve Your Website Design?
- How to use Intention.js for Responsive Design
- What Does a Degree in Architecture Have to Do with Web Design & Development?
- A Front-End Workflow For The Evolving Web
- Stop Writing Blog Posts: Ideas for Interactive Content
- Parallax Scrolling? HTML5 Animations? Why We’re Falling for New Design Techniques