Hacker News new | ask | show | jobs
by Dylan16807 2273 days ago
What if you have a cookie set by http and try to update it with js? Will it self-destruct now?
2 comments

Technically, when you update it via js you're overwriting the existing cookie with a new one. And, from my understanding, it's then subject to the same restrictions as any other cookie set client side.

So in order to have a long-lived cookie, you essentially need to treat them as read-only client side, and push any and all update/write logic to the server such that it'll return a set-cookie header with any changes you require.

I would guess is works, but expiration is capped at today + 7 days.