Check out these lines of code:
const session = require('express-session');
const sessionConfig = {
secret: 'somesecretkey',
cookie: {secure: false},
resave: false,
saveUninitialized: false,
store: new mongostore({ mongooseConnection: mongoose.connection })
}
router.get('/', function(req, res, next) {
let abc = req.session.user;
let trueOrFalse = isset(abc);
console.log(trueOrFalse);
req.session.user = 1;
req.session.save();
});
function isset(var1){
if( typeof var1 !== 'undefined' ) {
return true;
}
return false;
}
I expect the output to display 'false' for the first time and 'true' on subsequent page refreshes. However, it always shows 'false', indicating that the value is not being retained.
Any assistance would be greatly appreciated.