Get session object from `req.session` outside of request context
RixInGithub opened this issue · comments
Hello, Express support team. (I don't really know who am I asking :P)
I wanted to ask you one simple thing.
Let's say I got a session.sid
cookie pop out from nowhere. And, of course, I want to get the Session
object from the cookie value I somehow got.
I know, a very hypothetical question with no samples. And also a short one.
Can you help?
Nevermind. Found a solution, personal.
My solution:
Get a MemoryStore
from new (require("express-session/session/memory"))()
and give it as the store
option, then store.load
the cookie value.
UPDATE: After looking on NPM published source, you need to unsign the cookie using require("cookie-signature").unsign(YOURSIDHERE.slice(2))
, and also use store.get
instead of store.load