app.use(session({ name: SESS_NAME, secret: SESS_SECRET, saveUninitialized: true, resave: false, store: new MongoStore({ mongooseConnection: connection, collection: 'session', ttl: parseInt(SESS_LIFETIME) / 1000 }), cookie: { sameSite: true, secure: NODE_ENV === 'production', maxAge: parseInt(SESS_LIFETIME), path: '/' } })) I have that already in my app.js. When I log into my app, I set req.session.user by doing req.session.user = sessionUser;. In the same function, I log req.session.user and it shows the session user. However, when I do another GET request to a test path, router.get("", (req, res) => { res.send(req.session.user); }); req.session.user is undefined? req.session exists, and so does req.session.id.
Submitted December 29, 2019 at 09:47PM by HellD
No comments:
Post a Comment