robbie
robbie

Reputation: 1299

express-session is not saving user's session data

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.

Upvotes: 0

Views: 1639

Answers (1)

Ash
Ash

Reputation: 6783

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.

Upvotes: 2

Related Questions