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…

[cookies]

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):

wfwaf-authcookie-984153ea447fc496443ff94a1f9626bf
wordpress_logged_in_c04b9c66a59f8837e9fa1ae02bdefb0b
wordpress_test_cookie
wp-settings-1
wp-settings-time-1