From 4237b0be15d14db7019abf64123b9995a4874d42 Mon Sep 17 00:00:00 2001 From: Simon Tretter Date: Wed, 6 Sep 2017 17:01:24 +0200 Subject: [PATCH 1/3] add support for manual setting the session id --- index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 175fb234..4ec04268 100644 --- a/index.js +++ b/index.js @@ -75,6 +75,7 @@ var defer = typeof setImmediate === 'function' * @param {Boolean} [options.proxy] * @param {Boolean} [options.resave] Resave unmodified sessions back to the store * @param {Boolean} [options.rolling] Enable/disable rolling session expiration + * @param {Function} [options.sessionid] Manually set session ID * @param {Boolean} [options.saveUninitialized] Save uninitialized sessions to the store * @param {String|Array} [options.secret] Secret for signing session ID * @param {Object} [options.store=MemoryStore] Session store @@ -98,6 +99,8 @@ function session(options) { // get the session store var store = opts.store || new MemoryStore() + var getManualSessionId = options.sessionid || function(req) {}; + // get the trust proxy setting var trustProxy = opts.proxy @@ -155,7 +158,7 @@ function session(options) { // generates the new session store.generate = function(req){ - req.sessionID = generateId(req); + req.sessionID = getManualSessionId(req) ? getManualSessionId(req) : generateId(req); req.session = new Session(req); req.session.cookie = new Cookie(cookieOptions); @@ -213,7 +216,7 @@ function session(options) { req.sessionStore = store; // get the session ID from the cookie - var cookieId = req.sessionID = getcookie(req, name, secrets); + var cookieId = req.sessionID = getManualSessionId(req) ? getManualSessionId(req) : getcookie(req, name, secrets) // set-cookie onHeaders(res, function(){ From e5bc635536a9546251f3596bf82c5563f10e0769 Mon Sep 17 00:00:00 2001 From: Simon Tretter Date: Wed, 6 Sep 2017 17:03:49 +0200 Subject: [PATCH 2/3] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7e8527d8..e1719799 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "express-session", - "version": "1.15.5", + "version": "1.15.6", "description": "Simple session middleware for Express", "author": "TJ Holowaychuk (http://tjholowaychuk.com)", "contributors": [ From 657c478e74101d6ff284c4ef3ee849ec9c82dd4a Mon Sep 17 00:00:00 2001 From: simon Date: Thu, 25 Jun 2020 09:57:38 +0200 Subject: [PATCH 3/3] chore: rename package to @hokify --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index adadb821..c981740e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "express-session", + "name": "@hokify/express-session-manual", "version": "1.17.1", "description": "Simple session middleware for Express", "author": "TJ Holowaychuk (http://tjholowaychuk.com)",