I'm new to node.js and sessions, I'm trying to store some values in the node.js session, but everytime I reload the page and check the console.log the session haven't been saved. My code:
var session;
var org;
function checkSession(argument){
var sess = argument;
if(sess.org){
return null;
}
else{
return sess.org;
}
}
/* GET home page. */
router.get('/', function(req, res, next) {
session = req.session;
var sessionChecked = checkSession(session);
if(sessionChecked){
org = sessionChecked;
}
else{
org = req.query.org || 'Google';
session.org = org;
session.save();
}
So basically what I want is, when the user loads the page for the first time, he can type a organization, and when he does that, this organization is saved on the session, so when he reloads the page, the organization is already selected.
I know I must be doing something really wrong and/or bad codding, but I just can't figure this out.
Thank you!