π Do not use document.cookie directly.
πΌ This rule is enabled in the following configs: β
recommended, βοΈ unopinionated.
It's not recommended to use document.cookie directly as it's easy to get the string wrong. Instead, you should use the Cookie Store API or a cookie library.
// β
document.cookie =
'foo=bar' +
'; Path=/' +
'; Domain=example.com' +
'; expires=Fri, 31 Dec 9999 23:59:59 GMT' +
'; Secure';
// β
await cookieStore.set({
name: 'foo',
value: 'bar',
expires: Date.now() + 24 * 60 * 60 * 1000,
domain: 'example.com'
});// β
document.cookie += '; foo=bar';
// β
await cookieStore.set('foo', 'bar');
// β
import Cookies from 'js-cookie';
Cookies.set('foo', 'bar');// β
const array = document.cookie.split('; ');