Why does accessing the session object make Express-Session work?
My sessions suddenly stopped being saved, and cookies stopped being set. All routes were working, and Postman was also not receiving cookies (so I ruled out cors).
I discovered that accessing the session object immediately after the middleware fixed the issue. So this code was all that was needed:
in app.js. Remove this and again, no sessions are saved and no cookies set.
I can't see anything in the docs saying that the session object needs to be accessed? Does anyone know what's going on here?
1 Reply
Ugh... It's because
saveUninitialized
and resave
are false. I thought they applied to current sessions, but unless you alter a new session that session is also never saved