FREE EU Cookie Law Script
The EU Cookie Law deadline was the 26th May and if you haven’t already implemented the changes then we’ve put together a little bit of code to help you. Feel free to use this script on your site. A link back to our site would be grateful but not mandatory. Also, please do leave a message saying where and how you’ve implemented it.
Bear in mind you’ll still need to get your web developer to add this to your site as this is just the bare bones version and you’ll need to style it up a bit. If you haven’t already clicked “Accept” on the Dare to Think site then you’ll see how we’ve added a banner to the top of the site.
If you need either script added to your site or you’re unsure where to start please do get in touch for a quote.
NOTE 14/6/12: Thanks to Pete Norris of Liquid Engine as I think he’s managed to solve the mysterious reason why these scripts weren’t working in IE. I’ve changed the scripts below as well as uploaded new files for you to download
Version 1 – The user clicks “Accept” before the message is removed
This shows a message to the user and they must click the “Accept” button before the message is removed. After they click the link then a cookie is stored on their computer so the message doesn’t display again until the year 2022!! If you would like to change the cookie expiry date then change the 365*10 code below (365 is the number of days and 10 is the number of years).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <style type="text/css"> <!-- #eucookielaw { display:none } --> </style> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <?php if(!isset($_COOKIE['eucookie'])) { ?> <script type="text/javascript"> function SetCookie(c_name,value,expiredays) { var exdate=new Date() exdate.setDate(exdate.getDate()+expiredays) document.cookie=c_name+ "=" +escape(value)+";path=/"+((expiredays==null) ? "" : ";expires="+exdate.toGMTString()) } </script> <?php } ?> <title>EU Cookie Law Script 1</title> </head> <body> <?php if(!isset($_COOKIE['eucookie'])) { ?> <div id="eucookielaw" > <p>We use cookies. By browsing our site you agree to our use of cookies.</p> <a id="removecookie">Accept this cookie</a> <a id="more">Find out more</a> </div> <script type="text/javascript"> if( document.cookie.indexOf("eucookie") ===-1 ){ $("#eucookielaw").show(); } $("#removecookie").click(function () { SetCookie('eucookie','eucookie',365*10) $("#eucookielaw").remove(); }); </script> <?php } ?> </body> </html> |
Download version 1 of the Free EU Cookie law script now
Version 2 – The user only sees the message once
This shows a message to the user once and then stores the cookie so it is never shown again.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <style type="text/css"> <!-- #eucookielaw { display:none } --> </style> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> <?php if(!isset($_COOKIE['eucookie'])) { ?> <script type="text/javascript"> function SetCookie(c_name,value,expiredays) { var exdate=new Date() exdate.setDate(exdate.getDate()+expiredays) document.cookie=c_name+ "=" +escape(value)+";path=/"+((expiredays==null) ? "" : ";expires="+exdate.toUTCString()) } </script> <?php } ?> <title>EU Cookie Law Script 2</title> </head> <body> <?php if(!isset($_COOKIE['eucookie'])) { ?> <div id="eucookielaw" > <p>By browsing our site you agree to our use of cookies. You will only see this message once.</p> <a href="#" id="more">Find out more</a> </div> <script type="text/javascript"> if( document.cookie.indexOf("eucookie") ===-1 ){ $("#eucookielaw").show(); SetCookie('eucookie','eucookie',365*10) } else { $("#eucookielaw").remove(); } </script> <?php } ?> </body> </html> |