A Cookie Consent Modal for Kirby3

Hi Miachael!
Thanks for your great plugin.

I have some problems with the following scenario.
I would like to ban all cookies (even essential) until someone explicitly allows it. Unfortunately the “essential button” keeps activating itself.

I think this behavior is intended since those cookies are essential, therefore mandatory.

In case you really want to force an explicit activation for essential cookies you need to overwrite the plugin itself (See cookie-modal.php) and set :

'disabled' => false,
'checked' => false,

Thanks for your super fast reply!
I did exactly this before.

If I understand the functionality of the plugin correctly, i should only be able to see “I’m a cookie” if the user allows cookies. Unfortunately, I see it after a simple reload even if I have disallowed cookies before.

This is what I meant by “the ‘essential button’ keeps activating itself”.

<?php if (isFeatureAllowed('essential')): ?>
  <script>
     console.log("I'm a cookie!");
  </script>
<?php endif; ?>

Just discovered that “essential” is declared within the Javascript constructor:

this.MINUMUM_FEATURES = ['essential'];

So changing the PHP may not sufficient …
But I´m not that much into this plugin, maybe @michnhokn has an idea?

P.S. No Cookies, No banner :wink: :sweat_smile:

I knew. :wink:
Unfortunately a webshop without cookies is hard… There are no marketing or tracking cookies set but only cookies for the shopping cart of the store.

I’m not a lawyer, but as far as I can tell, you don’t need a cookie banner for a shopping cart cookie to comply with GDPR.

3 Likes

I agree, not a lawyer either, but purely functional cookies are no issue under GDPR or other cookie laws. I would even go as far as to say that such cookies don’t even need a cookie banner. Not all cookies are bad, after all, but make a website more usable.

1 Like

But this whole banner stuff doesn’t really make sense if you don’t allow any cookies. No cookies whatsoever => banner on every single page load, because your choice cannot be stored.

4 Likes

Hey michnhokn, thanks for the plugin! I wanted to ask what I can do if for some reason after clicking on the accept-button, the feature does not stay saved and the cookie banner appears on every reload again? Did anybody had similar issue? (the button works since I see it in the console). However deny-button works perfectly. I’m using your original plugin src and js assets

Sorry, I actually just managed to solve the issue by adding this.MAXIMUM_FEATURES = ["#cookie-accept"], instead this.MAXIMUM_FEATURES = [], on the line 80 in cookie-modal.js asset. Cheers

Hello! Any ideas on how to implement the logic for intercepting a script and execute it upon cookie consent?

Thanks @texnixe. My question was not very clear. I want to insert and execute Google analytics when the user consents, and without reloading the page. I am not sure if the GA javascript code executes by inserting it to the DOM using the cookies:saved event, or if some other method is required.

I don’t know how Google Analytics behaves in particular, but if it doesn’t work when injected from the cookies:saved event (= when injected from an arbitrary function after the page has loaded), it won’t work at all without reloading the page. I’d recommend to check this in the Google Analytics docs.

2 Likes

Is there currently a way to update cookie settings from outside the modal? I want the user to be able to commit to one specific cookie option with a single click of a button someplace else, without having to revisit the modal.

hello team,

I have just tried but seems doesn’t support K3 anymore

Hi @Tai_Nguyen,
Please make sure to use version 1.0.9 for Kirby 3.

composer require michnhokn/kirby3-cookie-banner:1.0.9
1 Like

Hi @michnhokn – thanks for the work you’ve done with this plugin! :clap:

But, as a graphic designer with elementary webcoding knowledge, I got trouble with putting it into action properly. Sorry for that :innocent:

After installing plugin manually on the remote server, I am missing its assets (CSS and JS files) in the front-end. Web inspector says that their path is set to the “media” folder from Kirby main directory, hence – 403 error occurs:

Deleting media folder in order to restore it helps for a while – assets are loading correctly, but only for the first visit at my front-end. On second and later attempts – 403 on assets back again.

What part of the set-up am I missing? Could you offer me some advice on that issue, please?