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

Some cookies are misusing the recommended “sameSite“ attribute #60

Open
randombrick opened this issue Sep 28, 2020 · 2 comments
Open

Comments

@randombrick
Copy link

how to handle this console error?

@sleepless-ninja
Copy link

Browsers now prefer for this to be specified rather for them to set it by default (which they'll do anyway).

I was trying to answer this one out myself. So I'll put this here for anyone else looking for the answer.

Before calling:

new CookiesEuBanner...

You put:

CookiesEuBanner.prototype.setCookie = function(name, value) {
  var date = new Date();
  date.setTime(date.getTime() + this.cookieTimeout);

  document.cookie = name + '=' + value + ';expires=' + date.toGMTString() + ';path=/' + ';secure;SameSite=Lax';
}

Tested it and it seems to work.

@andrewholgate
Copy link
Contributor

Yes this is indeed going to be an issue in the near future as browsers impose more strict control on cookies.

Firefox flags this issue with the following warning:

Cookie “hasConsent” will be soon rejected because it has the “SameSite” attribute set to “None” or an invalid value, without the “secure” attribute.
To know more about the “SameSite“ attribute, read https://developer.mozilla.org/docs/Web/HTTP/Headers/Set-Cookie/SameSite

andrewholgate added a commit to andrewholgate/Cookies-EU-banner that referenced this issue Jan 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants