# Remember Commenters' Details for 30 Days Instead of a Year

> Shortens how long the cookies that remember a commenter's name, email and website last, from WordPress's default of one year to 30 days.

- Type: PHP
- Runs: Run everywhere
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Tags: comments, cookies, retention
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-shorter-comment-cookies/

## Code

```php
// Days the comment author cookies are kept.
$wpide_comment_cookie_days = 30;

add_filter( 'comment_cookie_lifetime', function () use ( $wpide_comment_cookie_days ) {
    return (int) $wpide_comment_cookie_days * DAY_IN_SECONDS;
} );
```

## Notes

Change the number of days to suit your audience; the cookies are only set when the commenter ticks the consent box.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Remember Commenters' Details for 30 Days Instead of a Year" 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/
