Create a gist now

Instantly share code, notes, and snippets.

@tj /app.js
Created Dec 17, 2011

What would you like to do?
express 3.x cookie session middleware example
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);
@atian25

This comment has been minimized.

Show comment Hide comment
@atian25

atian25 Aug 3, 2012

TypeError: Object # has no method 'signedCookie'
-- should change to res.cookie(name, req.session, {signed: true});

atian25 commented Aug 3, 2012

TypeError: Object # has no method 'signedCookie'
-- should change to res.cookie(name, req.session, {signed: true});

@sgmonda

This comment has been minimized.

Show comment Hide comment
@sgmonda

sgmonda Oct 1, 2012

Fantastic!

sgmonda commented Oct 1, 2012

Fantastic!

@limoragni

This comment has been minimized.

Show comment Hide comment
@limoragni

limoragni Apr 16, 2013

Do you know how can I store the session using MongoDb (I'm using mongoose).

Do you know how can I store the session using MongoDb (I'm using mongoose).

@EFF

This comment has been minimized.

Show comment Hide comment
@EFF

EFF Apr 24, 2013

@limoragni, you can use session-mongoose, works fine but as explained, not ready for production ... https://github.com/donpark/session-mongoose

EFF commented Apr 24, 2013

@limoragni, you can use session-mongoose, works fine but as explained, not ready for production ... https://github.com/donpark/session-mongoose

@yanCode

This comment has been minimized.

Show comment Hide comment
@yanCode

yanCode Jul 8, 2013

res.signedCookie(name, req.session, { signed: true });

in both source code & official docs, there is NO res.signedCookie, but only res.cookie(name, req.session, {signed: true}); which works exactly as setting singed cookies!

yanCode commented Jul 8, 2013

res.signedCookie(name, req.session, { signed: true });

in both source code & official docs, there is NO res.signedCookie, but only res.cookie(name, req.session, {signed: true}); which works exactly as setting singed cookies!

@raynoppe

This comment has been minimized.

Show comment Hide comment
@raynoppe

raynoppe Nov 11, 2013

Is it possible to use couchDB for session storage?

Is it possible to use couchDB for session storage?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment