michnhokn / kirby-cookie-banner

A Cookie Consent Modal for Kirby
MIT License
67 stars 9 forks source link

Cookie only set on page refresh #13

Closed lam0r86 closed 2 years ago

lam0r86 commented 2 years ago

Hello,

got a problem. When cookies are accepted all or saved once, the code won´t start directly. I have to refresh the page, that the cookie is loaded. Are there any options to make a page refresh after accepting cookies?

BR Matthias

michnhokn commented 2 years ago

Hey Matthias,

have a look at: the wiki You can easyly replace the console.log() in the example with something like: location.reload();.

I hope that helps you.

lam0r86 commented 2 years ago

@michnhokn Thanks at all, but where do I change it? Sorry but I am not an really expert by this, but Iam familiar with php. If you can tell me where, then it would be easy for me :) #

Should it be changed inside of:

Sorry for complicated question :-/

Now I tried adding to cookie-modal.js with no effect

const $body = document.querySelector('body');
$body.addEventListener('cookies:saved', function(event) {
  location.reload();
  //console.log('Saved cookie features:', event.detail);
})
michnhokn commented 2 years ago

Hey @lam0r86,

No problem with pleasure. Best before the footer tag. Accordingly in the footer.php. There then simply wrap with a script tag:

<script> ... </script>

I hope this helps.

lam0r86 commented 2 years ago

Thanks to you @michnhokn yesterday i found Helpful script at getkirby. Now it is okay 😉 thanks

lam0r86 commented 2 years ago

Hey @michnhokn

How to add Cookie stuff to essential cookies?

<?php if (isFeatureAllowed('essential')): ?>

br Matthias

michnhokn commented 2 years ago

Hey @lam0r86

What excatly do you mean? You define what the essential cookies "contain" by yourself. There is no more features then saving the consent from the users in this plugin.