Closed wiscaksono closed 7 months ago
+1
I don't think there is a direct way to do it but here is how I am doing it. lucia.createSession
accepts a third argument { sessionId?: string }
. You can destroy the current session by lucia.invalidateSession(sessionId)
and create another one with the new attributes and sessionId.
await lucia.invalidateSession(session.id);
const session = await lucia.createSession(session.userId, newAttributes, { sessionId });
You have to call invalidateSession first, otherwise the unique constraint on sessionId will complain.
Lucia doesn't provide an API to update sessions - use your own driver/client/ORM
Is there a particular reason Lucia doesn't provide an API to update session data? I expected lucia.createSession(...)
to update the session data if an already existing sessionId
is being passed in. But instead it only performs an insert, resulting in duplicate entry errors.
Description
is there any way to update user session without relogin the app in next js app router?