I am developing an express application and i need to implement login and logout.
I have created a session using the following code during login.
req.session.login_id = rows[0][0]["login_id"];
req.session.save(function(err) {
if(err){
console.log('Error in creating session.')
}
else {
res.redirect('/profile')
}
})
But the following doesn't work to clear session:
router.get('/logout',(req,res,next)=>{
req.session.destroy(function (err) {
if (!err){
res.redirect('/')
}else{
return next(err)
}
})
})