Skip to content

Instantly share code, notes, and snippets.

@bjdixon
Forked from tj/app.js
Created August 30, 2014 01:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjdixon/1ce8ac8ce04524f27a60 to your computer and use it in GitHub Desktop.
Save bjdixon/1ce8ac8ce04524f27a60 to your computer and use it in GitHub Desktop.
cookie based sessions using express
var express = require('express')
, cookieSessions = require('./cookie-sessions');
var app = express();
app.use(express.cookieParser('manny is cool'));
app.use(cookieSessions('sid'));
app.get('/', function(req, res){
req.session.count = req.session.count || 0;
var n = req.session.count++;
res.send('viewed ' + n + ' times\n');
})
app.listen(3000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment