0

I'm getting "Some cookies are misusing the recommended “SameSite“ attribute " warning when trying to set a cookie on Firefox.

Already added "secure=true" in the code but that did not work.

I'm using the "universal-cookie" library

Here is the snippet;

  const cookies = new Cookies();

  cookies.set('session-id', jwtToken, {
    path: '/',
    domain: '.example.com',
    sameSite: 'none',
    secure: true,
  });

I think I clearly understand what the issue and security concern is, but apperantly suggestions I got on https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie/SameSite did not work for me, or I'm missing something.

akyayik
  • 664
  • 1
  • 8
  • 25

1 Answers1

0

you must set "same Site" to none and "secure" to true to avoid this error like they say: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Set-Cookie#samesitesamesite-value.

For example:

import Cookies from 'universal-cookie';

const cookies = new Cookies();

cookies.set('myCat', 'Pacman', { path: '/', 'sameSite': 'none', 'secure': 'true' });
console.log(cookies.get('myCat'));
Jourdelune
  • 131
  • 8