Reputation: 21
I use express-session
app.use(require('express-session')({ resave: false, saveUninitialized: false }));
And I would like to know if it's possible to keep sessions after NodeJS server restart ?
Thank you very much
(User is disconnected after every server reload)
Upvotes: 2
Views: 3310
Reputation: 1166
Sessions are stored in memory so if your NodeJS server restarts, all the session data is lost.
You will have to use a database to store the session data.
The documentation has a list of modules available to connect with the database.
https://www.npmjs.com/package/express-session#compatible-session-stores
Upvotes: 3