Saturday 29 April 2017

How to keep user logged in forever in express-session? Node.js

My users can login to my app. However after turning off the PC or after 4 to 5 hours the app asks my user to re-login. I want my users to never have to re-login unless they log out.

I do not know what I am doing wrong. I appreciate any help!

This is my code in my app.js:

app.use(session({
  secret: 'angular shhh secret auth',
  resave: true,
  saveUninitialized: true,
  cookie : {
    httpOnly: true,
    expires: new Date(253402300000000)
  } 
}));

app.use(passport.initialize());
app.use(passport.session());

const passportSetup = require('./config/passport');
passportSetup(passport);

I am using a Local Strategy to save the user.



via Walter Monecke

No comments:

Post a Comment