A simple drop-in JS script that will prompt your users to allow cookies on your site. As per the new EU law released on the 26th May.
JavaScript HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



Starting on May 26th 2011 sites for any organisation based within the UK (even if their site is hosted overseas) must seek consent to store cookies on a user's computer, or device. Failure to comply could result in a fine up to £500,000.


A live demo can be seen here, with some extra implementation information.

Who's behind it?


Q. Can I make it so that the prompt box hides when the user accepts cookies on the site?
A. You can use the following chunk of code:

cPrompt.hideOnAccept = true;

Q. Can I make it so that the prompt box is always minimised?
A.You can use the following chunk of code:

cPrompt.minimisePrompt = true;

Q. Is there a shorter & quicker way for me to find out if the user allows cookies?
A.You can use the following method which returns true if the user allows cookies to be stored:


Q. Does this protect me & my site against the law?
A. The requisites of every site differ, this is only a javascript solution, the cookie that is set can be accessed in server side code. If using this code, you need to ensure that it covers your site, however every effort has been taken to try to make this as compliant as possible.

Q. Can I set a 'Cookie Policy' URL for my visitors to read? I hear the law stipulates that I should have one.
A. You can use the following chunk of code to set a cookie policy URL that will appear in the prompts:

cPrompt.cookieLink = 'http://mycookiepolicy.com/me.html';

Q. What if the user has javascript disabled?
A. You could revert to a server side fallback, so that you are absolutely definitely covered.

Q. I'm being fined, I'm going to sue you 'cause you got me fined!
A. Well, this is a very dickish thing to do. By you using this you accept that it doesn't necessarily provide full protection & that you will ensure your own site protects you. Even from bears!

Q. This is pretty awesome, can I thank you?
A. Why not watch the code, follow me on Twitter, or simply share this! All of these are a sign of thanks, and make me feel warm & fuzzy inside.