hoangvvo/next-session

Session doesn't save

Closed this issue · 8 comments

The session does not save anything even though autoCommit is passed into the options. export default withSession(handler, { autoCommit: true, cookie: { maxAge: 2.628e9 } }); When I refresh and try to update the session before that, all the properties are gone. Is there a way to get that session by it's id? The docs aren't very clear about that.

This sounds like a bug. autoCommit should be true by default.

Are you using serverless mode?

Did you restart the server? The default MemoryStore will be cleared if the server is restarted.

Currently not severless, and the sever did not restart either. When I refresh the page all the session properties are gone, but when I log Object.keys(req.sessionStore.sessions) everything is in the memory store but there is no detailed documentation on how to access a specific one.

@semperfortis Can you provide a minimal reproduction. In the meantime, can you try downgrading to a lower version to see if it works?

I believe I worded my issue wrong, I meant to ask is there docs on accessing MemoryStore?

It is not in the doc, but you can do await req.sessionStore.get(sid) to get a session by an id

And the sid is the cookie value or req.sessionId?

Hey @semperfortis, so did the session persists or it is gone after you refresh the page?

Yes, the session persists. Thank you.