0

I have a 4.x express app. I would like to store data in the session after user has successfully logged in. When I try to access this data in another request the data is always undefined. Here is my code :

 app.use(expressSession({
    secret: 'keyboard cat',
    resave: false,
    saveUninitialized: false,
    cookie: {
        secure : false,
        httpOnly: true,
        maxAge: 3600000
    }
    
    
}));

After logIn I put the data into the session:

req.session.verficationCode = 123;

In each subsequent request the session data is lost ?

3
  • How do you finish the response after putting data into the session? Note that sessions are not updated after a redirect (stackoverflow.com/questions/72563237/…). Commented Dec 3 at 15:33
  • I dont use a Redirect. Just send the json response to the client
    – Jonas
    Commented Dec 3 at 18:21
  • When I use Postman I am able to login and call another request where the session id remains the same. If I use my Ember App for each request a new session is created. Seems that Ember App does not send the cookie back to the server
    – Jonas
    Commented Dec 4 at 11:41

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.