From e28ed490ee3ef84082fb40e5ec3cf048837d8a33 Mon Sep 17 00:00:00 2001 From: Aure77 Date: Thu, 24 Jul 2014 22:26:19 +0200 Subject: [PATCH] Allow session cookie domain customization --- src/middleware/index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/middleware/index.js b/src/middleware/index.js index 6c59c1709a..eb519498e7 100644 --- a/src/middleware/index.js +++ b/src/middleware/index.js @@ -167,13 +167,19 @@ module.exports = function(app, data) { app.use(bodyParser.json()); app.use(cookieParser()); + var cookie = { + maxAge: 1000 * 60 * 60 * 24 * parseInt(meta.configs.loginDays || 14, 10) + }; + var cookieDomain = nconf.get('cookie-domain'); + if(cookieDomain) { + cookie.domain = cookieDomain; + } + app.use(session({ store: db.sessionStore, secret: nconf.get('secret'), key: 'express.sid', - cookie: { - maxAge: 1000 * 60 * 60 * 24 * parseInt(meta.configs.loginDays || 14, 10) - }, + cookie: cookie, resave: true, saveUninitialized: true }));