Skip to content

Instantly share code, notes, and snippets.

@joshuathayer
Created April 1, 2011 06:40
Show Gist options
  • Save joshuathayer/897832 to your computer and use it in GitHub Desktop.
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.
// 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];
}
}
@tj
Copy link

tj commented Apr 1, 2011

yeah totally. although let's just make the option "key" or something, or at least camel-case like the rest of javascript

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