Session is always null inside a "before hook"
I am trying to access ctx.context.session inside a "before hook", and it is always returning null even when user is signed in.
Is this an expected behavior?
For context, I set up secondary storage (Upstash Redis), so sessions are there and not persisted on main database (postgreSQL with DrizzleORM). Also: no cookie caching.
2 Replies
use
getSessionFromCtx(ctx)
. On before hook session is most likely not have been fetched by the endpoint, so it could be null.
That works, thanks