index.js
This file
Path
examples/session/index.js
30 lines · 694 bytes · JavaScript
Last changed by
remove last pieces of connect dependencyRoman Shtylmanbefore adoption1396e08
History of this fileTake it
The walk stopped after 200 commits: lines older than 476fba3 point at it.
Release 3.1.1TJ Holowaychukbefore adoption476fba3
lines 1–30why, one step back12// first:3// $ npm install redis4// $ redis-server56var express = require('../..');78var app = express();910// Required by session() middleware11// pass the secret for signed cookies12// (required by session())13app.use(express.cookieParser('keyboard cat'));1415// Populates req.session16app.use(express.session());1718app.get('/', function(req, res){19 var body = '';20 if (req.session.views) {21 ++req.session.views;22 } else {23 req.session.views = 1;24 body += '<p>First time visiting? view this page in several browsers :)</p>';25 }26 res.send(body + '<p>viewed <strong>' + req.session.views + '</strong> times.</p>');27});2829app.listen(3000);30console.log('Express app started on port 3000');