Cookie comment life...
 
Notifications
Clear all

Cookie comment lifetime in seconds

5 Posts
3 Users
0 Reactions
1,100 Views
(@kaldata)
Member Customer
Joined: 8 years ago
Posts: 2
Topic starter  

I'm using a comment plugin wpDiscuz. When a guest adds a comment, the plugin adds two cookies:
comment_author_ and comment_author_email_ to remember the name and email of the user so they don't write them every time.

But then for wp-rocket this user is no longer a guest. And it stops loading the site from the cache for him. Until these two cookies are deleted, the cache does not work for him.

How do I set these cookies to lifetime 3 minutes?

In settings: Keep guest commenter credentials in browser cookies for x days

 

But the minimum is 1 day or 0 to clear those data when user closes browser.

 

Regards,


   
Quote
Elvina
(@elvina)
Support
Joined: 5 years ago
Posts: 1403
 

Hi @kaldata,

Please try to use the following code:

add_filter("wpdiscuz_js_options", function ($optionsJs) {
$optionsJs["storeCommenterData"] = (time() + 3 * MINUTE_IN_SECONDS) * 1000;
return $optionsJs;
});

You should add this code in the functions.php file of the current active theme.

Please don't forget to delete all caches and press CTRL+F5(twice) on the frontend before checking.


   
ReplyQuote
(@kaldata)
Member Customer
Joined: 8 years ago
Posts: 2
Topic starter  

Hi, tahanks, 

I tried many times. I deleted caches, pressed f5, but no result. Every time creates cookies with lifetime: Session 🙁


   
ReplyQuote
Elvina
(@elvina)
Support
Joined: 5 years ago
Posts: 1403
 

@kaldata,

The code provide above work only partly.

I'm sorry but we can't provide an exact solution for that, because for the cookie we use the js lib, that allows to set cookie only by days(not hours/ minutes and etc).

 


   
ReplyQuote
Astghik
(@astgh)
Illustrious Member Admin
Joined: 7 years ago
Posts: 6197
 

Hi @kaldata,

Currently, there is no solution we can provide you. However, we'll take this into consideration and may implement it in future updates if it'll be possible. 


   
ReplyQuote
Share:
Scroll to top