68publishers / cookie-consent

:cookie: Cookie-consent widget with GTM, GCM & CMP integration
MIT License
112 stars 28 forks source link

Is there an option for "autoclear_cookies" ? #19

Closed thorewi closed 2 years ago

thorewi commented 2 years ago

Hi,

is there an option for "autoclear_cookies" as it is in the original widget? Maybe I just didn't notice, but otherwise it should be added and I think it should be set to "true", although at original widget it is set to "false".

Thank you.

tg666 commented 2 years ago

Hello,

The option is not currently in the Template. But the option works only with Cookie tables so it's not only about the one option but also "cookie tables" must be configurable for each storage. https://github.com/orestbida/cookieconsent/blob/master/demo/app.js#L121

This also generates in the widget something like this:

Snímek obrazovky 2021-12-28 v 14 59 07

But it can be hide with an option remove_cookie_tables viz. original plugin configuration

I don't think html tables inside the settings modal are useful and another thing is that columns of tables are dynamically defined.

So my proposed solution is as follows:

thorewi commented 2 years ago

Your idea is probably the proper solution, but I don't want to specify all 3rd party cookies just because of this "almost nobody will use" function... I would be fine to remove all cookies except of "cc-settings"... e-commerce cart will get empty, maybe some popup will display again, what worse can happen? so maybe if someone specify the cookies, only this cookies will be removed, otherwise all except "cc-settings" ?

tg666 commented 2 years ago

Well it doesn't sound bad but this is not implemented by the original plugin. The option autoclear_cookies works only with cookie tables and cookies are removed when the user click on agree/reject button. At this moment are cookies for denied storages removed.

So the feature must be implemented in this wrapper. For clarification, the cookies should always be deleted with the page load until the user makes some action (click on accept all || accept necessary || save settings, etc.). Right?

thorewi commented 2 years ago

I think it should be deleted only when you withdraw any consent, use case:

1) I click "Accept all" - nothing is deleted... 2) Then I uncheck consent for ad_storage and analytics_storage and click "Save settings" - all cookies are deleted except "cc-setings"... 3) Then I click "Accept necessary" - nothing is deleted cause there is no change... 4) Then I click "Accept all" - nothing is deleted because these is no withdrawing, just granting...

thorewi commented 2 years ago

But I realized, that with my solution, if there is already saved cookies (lets say '_ga') from "opt-out" period and you click "Accept necessary", the '_ga' cookie won't be deleted. So maybe would be better to delete cookies every time when someone clicks on "Accept necessary" or "Save settings". I guess it would be also easier solution to implement, right? What do you think?

tg666 commented 2 years ago

I agree, cookies would be deleted when the user clicks on "Accept necessary" or "Save settings" and if there is some change (so don't delete cookies when the user clicks on "Accept necessary" multiple times, etc.).

But I have no time today/tomorrow so I can implement the feature on 2.1.2022.

thorewi commented 2 years ago

"and if there is some change or the button is clicked for the first time"...

tg666 commented 2 years ago

Hello, I implemented it and the feature will be in today's release 0.3.2.

Snímek obrazovky 2022-01-03 v 8 56 04

All you need for your UC is checked option Enable cookies auto-clear. Strategy Clear all except defined is selected by default when the option is checked (the strategy option is here primary for the future implementation of previously discussed cookie tables).

If you want to keep any other cookies than cc-settings (that is always kept automatically) then you can define them in the field Cookie names.