index.js
This file
Path
examples/cookie-sessions/index.js
27 lines · 577 bytes · JavaScript
Last changed by
examples: add missing cookie-session moduleYang Wangbefore adoption01e059c
History of this fileTake it
The walk stopped after 200 commits: lines older than 6bc7574 point at it.
docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 1–4why, one step back1/**2 * Module dependencies.3 */4examples: add missing cookie-session moduleYang Wangbefore adoption01e059c
line 5why, one step back5var cookieSession = require('cookie-session');docs: typo fixesDouglas Christopher Wilsonbefore adoption6bc7574
lines 6–27why, one step back6var express = require('../../');78var app = module.exports = express();910// add req.session cookie support11app.use(cookieSession({ secret: 'manny is cool' }));1213// do something with the session14app.use(count);1516// custom middleware17function count(req, res) {18 req.session.count = req.session.count || 0;19 var n = req.session.count++;20 res.send('viewed ' + n + ' times\n');21}2223/* istanbul ignore next */24if (!module.parent) {25 app.listen(3000);26 console.log('Express started on port 3000');27}