I have create a web application using sails js. Following is logout function.
logout: function(req, res) {
      req.session.destroy(function(err) {
           res.redirect('/');
      });
}
Sometime user does not logout from one click. But anyway user is redirecting to my home page. Then I have to click again logout button to logout the user.
Send them to a logout page instead of a redirect or put a timeout in the callback.
logout: function(req, res) {
      req.session.destroy(function(err) {
           return res.view('/logout');
      });
}
or
logout: function(req, res) {
      req.session.destroy(function(err) {
           timeout(function(){
               return res.redirect('/');
           }, 1000);
      });
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With