Created
April 1, 2011 06:40
-
-
Save joshuathayer/897832 to your computer and use it in GitHub Desktop.
demonstrating get_key function, which pulls session id out of query parameters if present, otherwise from cookie.
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
// in app.js: | |
// ... | |
app.use(express.bodyParser()); | |
app.use(express.cookieParser()); | |
app.use(express.session( { secret: 'verySecret', get_key: session.get_session_key })); | |
// ... | |
// in session.js (of my app): | |
exports.get_session_key = function(req,key) { | |
if (req.param('session_id')) { | |
return req.param('session_id'); | |
} | |
if (req.cookies) { | |
return req.cookies[key]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
yeah totally. although let's just make the option "key" or something, or at least camel-case like the rest of javascript