Tulip Media

Entrepreneurial thoughts

Month: April 2012

Specify cookie expiration time (or delete them) from WordPress comments

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!

 

My latest tweets

New shorts on Blooness 👉 Training dedicated to the best oilseeds for health is finally available in audio format https://buff.ly/3xo9fTS
https://buff.ly/43DkrYR

New shorts on Blooness 👉 If there was only one supplement to take, it would be magnesium (along with vitamin D). The complete guide to the best multivitamins on the market still available here with free access https://buff.ly/49bHqvp
https://buff.ly/49c3rKK

New shorts on Blooness 👉 The latest Blooness training on #proteins is available in audio format https://buff.ly/4aijbMW
https://buff.ly/3TP67cB

Load more

Don't miss business advice by email

No spam, just an email when new content is published.

en_USEN