Closed go4cas closed 6 months ago
Yes. You can use the Session#state
property to add metadata to sessions (as well as channels).
If you're using TypeScript, you can add type information to the metadata object via generics when you create the session:
const session = createSession<{email: string}>();
session.state.email = "example@gmail.com";
session.state.email = 12345; // TypeScript Error: Type 'number' is not assignable to type 'string'.
Or you can change the default session state for all sessions using module augmentation and declaration merging and adding properties to the DefaultSessionState
interface.
See #47.
I'm really keen on using this library in a real-time dashboard stack, using unjs' Nitro server. I just a few questions (which I could not find answers for in the docs):
Session
). This could include data like user-agent, user identifier (internal ID, email, IP address, etc), connection timestamp, etc. Is this supported at the moment?