Below WordPress, THE cookie expiration time stored on the computer of the Internet user who commented your blog is extremely long (approximately a year). There are several reasons why a blogger might want to reduce this timeout, starting with improving performance and the desire to have faster page loading. Indeed, one of the pet peeves of bloggers who use the plugin for example W3 Total Cache is the famous mention “Cookie is rejected”, which causes the no caching of pages. In fact, the site is no longer hidden from Internet users who have commented on articles.
Cookies are used to store information about the commentator, which allows them in particular not to fill in the “nickname”, “email” and “website” fields for each comment. If this option is useful for active commenters, it is much less useful for those who comment rarely, and who find themselves deprived of a cache.
So, for reduce cookie expiration time for commenters, and allow pages to be hidden even for an Internet user who has left a comment on your blog, here is a little hack to add to your sacrosanct functions.php.
[icon style=”chain” color=”red”]functions.php[/icon]
[coded]
add_filter('comment_cookie_lifetime', 'my_comment_cookie_lifetime');
function my_comment_cookie_lifetime($lifetime) {
return 259200;
}
[/coded]
And there you have it, thanks to this little piece of code, you set the cookie expiration time to 259,200 seconds, or 72 hours!
Thanks to Shibashake, where you will find other tips related to W3 Total Cache.
Update :
Since the new EU cookie standards, you are required to have your visitors' permission to store "non-essential" cookies. To avoid pop-ups and other unwanted requests which – let’s face it – are more annoying for the user than the cookie itself, here is a way to delete cookies used to store commentator information:
[coded]
remove_action( 'set_comment_cookies', 'wp_set_comment_cookies' );
[/coded]
Obviously add to your functions.php file. Also useful for optimizing your cache!
One Response
WordPress3.6
remove_action( 'set_comment_cookies', 'wp_set_comment_cookies' );
not work.
Why?
http://wordpress.org/support/topic/how-to-disable-comment-cookies