Answer the question
In order to leave comments, you need to log in
Sessions not working on post requests?
Hello everyone, I think it's been 8 hours on a simple task.
I use express-session with these settings:
resave: true,
saveUninitialized: false,
secret: 'splashsecretsession',
store: new FileStore(),
cookie : { secure : false, maxAge : (4 * 60 * 60 * 1000), httpOnly: false }
If doing
Router.get('/login', sessionMiddleware, (request, response, next) => {
console.log(request.session);
request.session.test = 'test3';
request.session.save ();
Everything works. By opening /login 2 times, I will see the saved session.
But if you change .get to .post and call this request, then the session is not saved. More precisely, each time it is saved as a new one and reset to zero when it is called again. You need to somehow save the POST session
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question