h3 icon indicating copy to clipboard operation
h3 copied to clipboard

session utils don't mention anything about the `name` in the config

Open datner opened this issue 10 months ago • 0 comments

Describe the change

I don't mean that it accepts a name, but rather that the implementation is built in such a way to support multiple sessions at the same time

const session = await useSession(event, { name: 'foo', ..})
const session2 = await useSession(event, { name: 'bar, ..})

session.id !== session2

This is very useful for holding different references for different things without bloating the very very restrictive space a cookie can hold. Most commonly, this can be used for flashing data. Something I had to enhance my unstorage driver layers can be done for free. It's a shame really..

Is there a reason for that? If so, is there a reason why it is a map at all?

URLs

https://h3.unjs.io/examples/handle-session

https://h3.unjs.io/utils/advanced#session-utils

Additional information

  • [ ] Would you be willing to help?

datner avatar Feb 04 '25 22:02 datner