Remix.run Logo
robgibbons a year ago

In both cases (cookie vs localStorage) you're really just storing your data as a string value, not truly a JSON object, so whether you use a cookie or localStorage is more dependent on the use case.

If you only ever need the stored data on the client, localStorage is your pick. If you need to pass it back to the server with each request, cookies.

recursive a year ago | parent | next [-]

JSON is explicitly a string serialization format.

robgibbons a year ago | parent | next [-]

Right, I meant it's not a JavaScript object. It's serialized into a string in any case, no matter which API you're stuffing it into. So it's a bit of a non-sequitur for the parent to suggest that it's somehow weird to store JSON in a cookie, but not in localStorage. It's all just strings.

a year ago | parent | prev [-]
[deleted]
0x073 a year ago | parent | prev [-]

Combine local storage with service worker, so you pass the data to the server if needed. Completely without setting cookies.

withinboredom a year ago | parent [-]

And if I don't want any javascript to see my values, ever? Or how do you handle CSRF?