Permalink
Browse files

Update chapter6.md

`res.redirect` must be executed after `req.session.destroy`

in code below ...
```
exports.logout = (req, res, next) => {
  req.session.destroy((err) => {
    if (err) return console.log(err);
    console.log('in');
    res.redirect('/');
  });
  console.log('out');
}
```
```
output:
out
in
```
  • Loading branch information...
Kan-Artem committed Oct 29, 2018
1 parent e3b02da commit 7495447e4c83e7f2b17b1b1e1982b6092426aca4
Showing with 4 additions and 2 deletions.
  1. +4 −2 chapter6/chapter6.md
@@ -517,8 +517,10 @@ The `logout` route is trivial. We clear the session by calling `destroy()` on `r
```js
exports.logout = (req, res, next) => {
req.session.destroy()
res.redirect('/')
req.session.destroy((error) => {
if (error) return console.log(error)
res.redirect('/')
})
}
```

0 comments on commit 7495447

Please sign in to comment.