W
W
Wasya UK2017-04-25 11:33:46
JavaScript
Wasya UK, 2017-04-25 11:33:46

How to keep user logged in in Node.js?

Authorization happens with the help of passport . Sessions are stored in the database:

var session = require('express-session');
var MongoStore = require('connect-mongo')(session),
    sessionStore = new MongoStore({ url'mongodb://localhost:27017/loginapp' });

module.exports = sessionStore;

Everything works fine, but when the user closes the browser and tries to log in again, he is redirected to the login page. How to make the server understand that if the user has not logged out, then he is authorized. Sorry for the weird wording

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
napa3um, 2017-04-25
@dmc1989

https://github.com/expressjs/session
Pay attention to the parameters cookie.expires and cookie.maxAge (you can use any of them).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question