js-cookie samesite and httpOnly

Viewed 8465

I'm using js-cookie 2.2.0 and I would like to add the samesite flag but i don't find anything about.

Here my actual code.

Cookies.set('traffweb' + cookieName, cookieStr, {
  expires: 7,
  path: window.location.href,
  secure: true
})

how can I add a samesite flag?

3 Answers

I added a "sameSite" attribute and the warning went away

Cookies.set('name', 'value', { sameSite:'strict' });

For SameSite=None + Secure:

    Cookies.set('name', 'value', {sameSite: 'None', secure: true});

From what I can gather, "sameSite" is intended to be added in a future release of js-cookie, beyond 2.2.1. It is mentioned in the docs for the master branch of js-cookie on GitHub (https://github.com/js-cookie/js-cookie/tree/latest#readme).

Whether this represents an actual code change or just a documentation update, I don't know. Setting sameSite='strict' did not eliminate the warning that I have been receiving. My own app does not need to pass cookies cross-site, so I am just ignoring the warning for now.

The answer, then, would seem to be to wait for a future version, assuming that an actual js-cookie code change will be required.

Related