0

express-session is refusing to save the session data for my users.

It is saving the session cookie, but the data is not persisting.

Here is my server.js.

robbie
  • 1,219
  • 1
  • 11
  • 25

1 Answers1

2

It seems you are setting the following (line #31):

req.session.user = user;

But inside the base '/' route (line #21) you are checking for :

req.session.userName

Which doesn't exist, so the if statement will fail. To double check, you can always log the req.session to console to check what data is getting stored.

Ash
  • 6,483
  • 7
  • 29
  • 37