WordPress function to list site cookies

Tutorial Difficulty Level    

The EU Cookie Directive (as it is popularly known) is a 2009 amendment to the E-Privacy Directive. It requires companies to obtain your consent to place and access data (like cookies) on your digital device (like your laptop). While many plugins exist to control cookies on your WordPress website, there is a shocking lack of them to simply LIST the cookies used.. so let’s write our own!

Add the code below to the functions.php file in your theme folder.

Now use the following shortcode in a post or page…


Simple, eh? This will list all the site’s cookies along with their values. Two further options are available…

[cookies novalue]

This will now output the cookie values.

[cookies] ==> [/cookies]

Now by providing a value between opening and closing shortcodes you can override the text that is used to separate the cookie name and the value!

Here’s how it looks on this very website (without the values):