Skip to content

Commit

Permalink
examples: improve view count in cookie-sessions
Browse files Browse the repository at this point in the history
closes #5414
  • Loading branch information
Dmitry-Kondar authored and dougwilson committed Feb 19, 2024
1 parent 59af63a commit 0e3ab6e
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions examples/cookie-sessions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@ var app = module.exports = express();
app.use(cookieSession({ secret: 'manny is cool' }));

// do something with the session
app.use(count);

// custom middleware
function count(req, res) {
app.get('/', function (req, res) {
req.session.count = (req.session.count || 0) + 1
res.send('viewed ' + req.session.count + ' times\n')
}
})

/* istanbul ignore next */
if (!module.parent) {
Expand Down

0 comments on commit 0e3ab6e

Please sign in to comment.