EU law in its infinite wisdom now requires web sites to be explicit about Cookie usage.

I am not going to explore the legal rights or wrongs of these regulations. If you want more information see:

Any EU web users will by now have seen these “cookie consent” forms pop up on their favourite sites. To make it easier to add your own cookie consent checker I have put together a simple jQuery Plugin.

See the Demo.

Download the Files (zip).

How to use

In the ZIP you find everything you need.

1. Load jQuery and the ‘cookieChecker.js’ plugin file. ie:

<script src=""></script>
<script src="js/cookieChecker.js"></script>

2. Attach the plugin to the <body> tag.

You can do this at the bottom of the file before <body> like so:


Alternatively, if you prefer add a jQuery $(document).ready function to the <head> of the document like this:


In either case attach the plugin to the <body> tag.

3. Change the Default Parameters

The plugin has the following optional parameters.

Name of the cookie to be created – default name ‘policyAgreed’
The path to the HTML file to be used to hold the consent message. Create and style your own file or the edit the default ‘js/cookieMsg.html’
Length in years for cookie to persist – default name 3 years

For example:


3. Customize the Message

To customize the message open the ‘cookieMsg.html’ file. Use the CSS file to format to taste.

Finally you should also put together your own cookie policy file outlining what cookies you have used. Here is an example I used.

Any comments, suggested improvements welcome.

6 Thoughts to “EU Cookie Law – Cookie Consent Checker jQuery Plugin”

  1. Charles Litster

    Good solution. It appears to be javascriot driven. Therefore it may fail if javascript is switched off. Should that happen the visitor still needs to be made aware of cookies and give consent. That is either give implied or explicit consent in full knowledge of the cookies being used. Shoukd you need any help please let me know.

    1. admin

      Yep, afraid so. This is solution does require Javascript. You can use PHP to detect the presence of cookies with $_COOKIE superglobal ie

      echo "You need cookies here etc";
  2. I have tried to install this but it will not work. It´s a php site. want to install it in de header.tpl but no result.
    What information do you need to add and where??
    body = What”
    ( ) what info needs to be added if so ??

    1. admin

      Take a look at the demo page. If you view the source you’ll see I’ve added calls to jQuery and then the cookieChecker plugin in the of the document.

      <script src=""></script>
      <script src="js/cookieChecker.js"></script>

      Then just before the closing I have initialised the plugin ie:

      <script language="JavaScript" type="text/javascript">

      How you get those into you PHP setup depends on your architecture of includes. For example you may have a file like ‘’ where you put the script tags calling jQuery and the cookieChecker.

  3. Artur

    Great plugin, everything works perfectly fine !
    Many Thanks

  4. dave

    works like charm! thanx

Leave a Comment