Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Subdomain changes in the domain settings can lead to breaking the bar #683

Open
jelen07 opened this issue May 10, 2024 · 1 comment
Labels
bug Something isn't working triage yet to be reviewed

Comments

@jelen07
Copy link

jelen07 commented May 10, 2024

Expected Behavior

If user set consent on some particular domain/subdomain, the cookie bar should read from the relevant cookie.

Current Behavior

The cookie bar gets the first cookie it gets, which can lead to a broken cookie bar (still showing).

Steps to reproduce

  1. Set domain to your domain like www.example.com
  2. Store consent (accept all)
  3. Change it to .example.com
  4. Store consent (accept necessary)

or vice versa

Proposed fix or additional info.

It's related to how cookies are stored and read, see https://stackoverflow.com/questions/4056306/how-to-handle-multiple-cookies-with-the-same-name/24214538#24214538

68publishers/cookie-consent#79 (comment)

I'm not sure if this can be fixed at the cookie reading level. If not, at least a mention in the documentation would be good, as this can break the site - the bar will show up on every request, or the changes won't be saved and you'll lose analytics.
To be precise, the changes will be saved, but they will be read again from the bad one - the original one.

Version

all

On which browser do you see the issue?

No response

@jelen07 jelen07 added the bug Something isn't working label May 10, 2024
@github-actions github-actions bot added the triage yet to be reviewed label May 10, 2024
@jelen07
Copy link
Author

jelen07 commented May 14, 2024

We're using this JS snippet as a hotfix in GTM. Note the URL www.exmaple.com - this is because we use the .example.com, so it removes the previous set one.

<script>
    CookieConsentWrapper.on('init', function () {
        var cookieName = CookieConsentWrapper.unwrap().getConfig('cookie_name');

        if (1 < document.cookie.split(/;\s*/).filter(function (c) {
            return cookieName === c.split('=').shift();
        }).length) {
            CookieConsentWrapper.unwrap().eraseCookies([cookieName], undefined, 'www.example.cz');
        }
    });
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working triage yet to be reviewed
Projects
None yet
Development

No branches or pull requests

1 participant