Created
December 17, 2011 23:15
-
-
Save tj/1491756 to your computer and use it in GitHub Desktop.
express 3.x cookie session middleware example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
Fantastic!
Do you know how can I store the session using MongoDb (I'm using mongoose).
@limoragni, you can use session-mongoose, works fine but as explained, not ready for production ... https://github.com/donpark/session-mongoose
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!
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
TypeError: Object # has no method 'signedCookie'
-- should change to res.cookie(name, req.session, {signed: true});