Answer the question
In order to leave comments, you need to log in
Why isn't the session saved in mongoDB?
Good afternoon! I'm taking a course on Vue, I'm not very friendly with the back. There was a question with saving sessions.
Here is the source code:
const session = require('express-session');
const passport = require('passport');
const MongoDBStore = require('connect-mongodb-session')(session);
const store = new MongoDBStore({
uri: config.DB_URI,
collection: 'mySessions'
});
store.on('error', (error) => console.log(error))
const app = express();
app.use(session({ secret: config.SESSION_SECRET,
cookie: {maxAge: 3600000},
resave: false,
saveUninitialized: false,
store
}));
app.use(passport.initialize());
app.use(passport.session());
Answer the question
In order to leave comments, you need to log in
resave: false,
saveUninitialized: false,
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question