nodejs express req.session not storing my variable
Well,
Finally I found why this wasn't working. I did the res.redirect outside my Admin.findOne function. So the client was redirected before the session variable was set.
This authCallbackFunction is working :
exports.authCallback = function (req, res, next) { //Check if the logged in user is an admin Admin.findOne( { user : req.user.id },function ( err, admin, count ){ var old = req.session; if(!err && admin) req.session.isAdmin = true; res.redirect('/') })}
And when the user logout, don't forget to regenerate the session
// logoutexports.logout = function (req, res) { req.session.regenerate(function(){ req.logout() res.redirect('/login') })}