Cookiebot: Problem with deleting cookies after user has changed consent

395 views Asked by At

I am working on React app which uses Cookiebot for dealing with cookies. Problem is, we have noticed that if user changes his previous consent (be it disabling cookies at all, or just certain category) cookies belonging to disabled category/categories are still there when I check the Application tab in browser's dev tools.

I have tried to implement such code to handle this:

if (typeof Cookiebot !== 'undefined' && typeof CookieControl !== "undefined" ) {    
    const CookiebotCallback_OnDecline = function() {
        if (!Cookiebot.consent.statistics || !Cookiebot.consent.preferences || !Cookiebot.consent.marketing) {
            Cookiebot.runScripts();
        }
}
    CookiebotCallback_OnDecline();
}

I'm using the runScripts method, because according to Cookiebot's documentation:

Evaluates all loaded script tags of type “text/plain” with the attribute “data-cookieconsent” and executes the scripts in accordance with the user’s consent state. For use by websites that load content dynamically, e.g. in single page applications. Scripts are only executed once, so this function is safe to call several times, e.g. every time new content is loaded.

Does anyone knows what am I doing wrong?

0

There are 0 answers