cookieconsent icon indicating copy to clipboard operation
cookieconsent copied to clipboard

[Docs]: I couldn't make a event listener listen for cookie change and reload the page

Open ItsSharkFinStudio opened this issue 1 year ago • 2 comments

Hello,

I have a question how can i make a listener that listens for cookie withdraw or change and make the page reload.

Best regards, ItsSharkFinStudio

ItsSharkFinStudio avatar Nov 30 '24 10:11 ItsSharkFinStudio

You can use onChange callback. See documentation.

CookieConsent.run({
  categories: {
    necessary: {
      readOnly: true,
      enabled: true,
    },
    analytics: {},
    ads: {},
  },

  language: {
    default: 'en',

    translations: {
      en: './en.json',
    },
  },

  onChange: () => {
    location.reload();
  },
});

OndraM avatar Dec 17 '24 14:12 OndraM

Oh thanks man but i have a question if i change cookie consent to deny the cookies remain loaded and if i reload the page they disappear do i need to make it reload the page on cookie consent change or not?

Best regards, ItsSharkFinStudio

ItsSharkFinStudio avatar Dec 20 '24 19:12 ItsSharkFinStudio