News for hackers. Stuff that matters.
Re:Introducing Workers KV by webjames on Friday September 28, 2018 @09:08AM (#18092980)
With the shopping cart example, I'm not sure I understand how session identity can be preserved if I clear my local storage/cookies?
Re:Introducing Workers KV by zackbloom on Friday September 28, 2018 @09:20AM (#18093059)
It's moving that shopping cart data from being stored at a single origin, to being stored in the network all around the world. The advantage of that in that use-case is you can render your site just as quickly as if it was a static website, but it can contain the customer's personal shopping cart data.
Re:Introducing Workers KV by adrianmonk on Friday September 28, 2018 @01:31PM (#18095216)
The shopping cart is still stored somewhere, but when the user has cleared their cookies, etc., what information do you have that will let you it's their shopping cart so you can find it again?

There's a (K,V) pair somewhere, but in order to get V, you need K, which you've lost.

Re:Introducing Workers KV by zackbloom on Friday September 28, 2018 @02:07PM (#18095585)
It would work just as most shopping carts do I imagine. You could store a session id in a cookie, and then use the data in KV to map that session id to a user account (if they're logged in) and their cart. So you would have a namespace full of sessions, and a namespace full of carts.

You could also store carts by session id until they're logged in, and then store the carts by account id when they are.

Re:Introducing Workers KV by adrianmonk on Saturday September 29, 2018 @01:52AM (#18098913)
> You could store a session id in a cookie

But the person you responded to asked what happens after "I clear my local storage/cookies". So you don't have access to the session id. It was in a cookie that is now gone.

Re:Introducing Workers KV by BHSPitMonkey on Friday September 28, 2018 @02:02PM (#18095545)
If the user signs in, move their shopping cart data from a key derived from their session ID to a key derived from their account ID. When a user is signed in, data is read from the latter.
Re:Introducing Workers KV by ericcholis on Friday September 28, 2018 @09:12AM (#18093010)
You'd still need some identifier, ie: a cookie, to link the KV store and your session.