# Cookie List Table Shortcode

> Adds a [cookie_list] shortcode that prints a clear table of the cookies your site uses, with provider, purpose and duration, for your cookie or privacy policy page.

- Type: PHP
- Runs: Frontend only
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Tags: cookies, shortcode, privacy-policy
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-cookie-list-shortcode/

## Code

```php
// Name, provider, purpose, duration.
$wpide_cookie_list = array(
    array( 'wordpress_logged_in_*', 'This site', 'Keeps you logged in.', 'Session or 14 days' ),
    array( 'wp-settings-*', 'This site', 'Remembers editor and admin preferences for logged-in users.', '1 year' ),
    array( 'comment_author_*', 'This site', 'Remembers your name and email for the comment form, if you agree.', '1 year' ),
    array( 'wpide_consent', 'This site', 'Remembers your cookie choice.', '6 months' ),
    array( '_ga, _ga_*', 'Google Analytics', 'Counts visits anonymously, only after you consent.', '2 years' ),
);

add_shortcode( 'cookie_list', function () use ( $wpide_cookie_list ) {
    $html = '<div class="wpide-cookie-table" style="overflow-x:auto"><table><thead><tr><th scope="col">Cookie</th><th scope="col">Provider</th><th scope="col">Purpose</th><th scope="col">Duration</th></tr></thead><tbody>';

    foreach ( $wpide_cookie_list as $row ) {
        $html .= '<tr>';
        foreach ( array_pad( $row, 4, '' ) as $i => $cell ) {
            $html .= 0 === $i ? '<td><code>' . esc_html( $cell ) . '</code></td>' : '<td>' . esc_html( $cell ) . '</td>';
        }
        $html .= '</tr>';
    }

    return $html . '</tbody></table></div>';
} );
```

## Notes

Keep the list in the snippet up to date whenever you add or remove a tool that sets cookies.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Cookie List Table Shortcode" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
