How to customize the comment cookie expiration time in WordPress

In WordPress, the default comment cookie expiration time is up to 30 000 000 seconds. That’s very long, especially for bloggers who are using cache plugins like W3 Total Cache. In fact, this plugin is not caching pages for visitors who have left comments on your blog, because of cookies, and until the cookie is cleared the plugin informs that cookie is rejected.
If you want to reduce the comment cookie expiration time, you have to play with the comment_cookie_lifetime filter in your functions.php file. You may set the expiration time you want, I chose 259 200 seconds in this example.
[icon style= »chain » color= »red »]functions.php[/icon]
[code]
add_filter(‘comment_cookie_lifetime’, ‘my_comment_cookie_lifetime’);
function my_comment_cookie_lifetime($lifetime) {
return 259200;
}
[/code]
Via

Une réponse

  1. I am really impressed with your writing skills as well as with the layout on your weblog.
    Is this a paid theme or did you modify it yourself?
    Either way keep up the excellent quality writing, it is rare to
    see a nice blog like this one these days.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée.