const express = require('express');
const app = express();
const session = require('express-session');
app.use(session({
secret: 'key',
resave: false,
saveUninitialized: true,
cookie: {
maxAge: 100000,
secure: true
},
}));
app.post('/a',function(req, res) {
req.session.name = 'Thomas';
});
app.post('/b', function(req, res) {
console.log(req.session.name) //undefined
});
I have two requests for a and B, set up session through a, and then undefined when visiting B. Why?
secure: true is saving the cookie to https are you accessing this via http? if you are accessing this via http it will return no cookie.
secure :false I've set it up, but it doesn't work.
I solved the problem, which is the default of fetch not sending cookied.
Most helpful comment
I solved the problem, which is the default of fetch not sending cookied.