David Artiss

WordPress function to list site cookies


Due to updates, over time, that have been made to the site and the age of this article, this post may not display correctly. In particular images may be missing or product reviews display incorrectly.

If this is the case and you'd particularly like me to fix it, then please reach out to me on Twitter.

Photo credit: nettsu

Having recently reviewed the WordPress plugins that are available to assist with the current cookie legislation I was dismayed to find a lack of anything simple that would be list out the shortcodes on a site, yet provide some flexibility.

So, I’ve written something. Add the code below to the functions.php file in your theme folder and then 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 not output the cookie values.

[cookies] ==> [/cookies]

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.

I have now updated the script to show the cookies in alphabetical order. In addition the output is presented as an unordered list.


ProductTesting.uk.com and why you should avoid them » « Targus City.Gear 15 Laptop Case

3 Comments

  1. Thank you, David!

    That’s exactly what I was looking for.

  2. Thank you, you are a star. Was looking for exactly this and could not find it anywhere.

  3. Hello, I’ve tried the script but it shows only 3 cookies of the 8 (I’m logged in)

Talk to me!

Copyright © 2017 David Artiss

Theme by Anders NorenUp ↑

Scroll Up
%d bloggers like this: