From f5a9f875be39e9bb97f6f83724c78134a62d293e Mon Sep 17 00:00:00 2001 From: Tim Brown Date: Wed, 21 May 2014 18:45:02 -0700 Subject: [PATCH 1/2] feat: adds optional sessionID getter rather than hard-coding the cookie method --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index abfe723d..ac4e8518 100644 --- a/index.js +++ b/index.js @@ -200,7 +200,7 @@ function session(options){ } // get the sessionID from the cookie - req.sessionID = unsignedCookie; + req.sessionID = ( options.getSessionID ? options.getSessionID(req) : null ) || unsignedCookie; // generate a session if the browser doesn't send a sessionID if (!req.sessionID) { From 2eede1bfde2c16275aca58e7a6f2e36ff2061553 Mon Sep 17 00:00:00 2001 From: Tim Brown Date: Wed, 21 May 2014 19:21:09 -0700 Subject: [PATCH 2/2] fix: updates readme with new options --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index a4a8810e..aaf5b78d 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ middleware _before_ `session()`. - (default: `{ path: '/', httpOnly: true, secure: false, maxAge: null }`) - `rolling` - forces a cookie reset on response. The reset affects the expiration date. (default: `false`) - `resave` - forces session to be saved even when unmodified. (default: `true`) + - `getSessionId` - a function that takes the incoming request as an argument and returns the session id. If it returns null or undefined it still falls back to using the cookie. + - Example: `function(req) { return req.query.session_id }`. #### Cookie options