JS - How to update cookies to samesite none

Viewed 1159

I am working with a third party js script. The third party script sets cookies, but doesn't set them to samesite=none and secure. This is problematic because a call is later made to this third party. and i get "Issues" in the chrome developer panel that says Indicate whether to send a cookie in a cross-site request by specifying its SameSite attribute. It tells me i have 18 cookies that were filtered out of each request because the sameSite attribute was defaulted to Lax.

Question: Is there anyway to update all cookies under a given domain and set their attribute of sameSite to be None?

2 Answers

I would suggest using cookiejs and run the below script

document.cookie.split(';').map(cookie => {
 const _cookie = cookie.split('=')
 Cookies.set(_cookie[0], _cookie[1], { sameSite: 'none' })
})

Note that more recent browsers are making "Lax" the default value even without specifiying anything here.

Related