From 0aa5e6864338a1ea84277e3c2bcc9e90d794c664 Mon Sep 17 00:00:00 2001 From: Liran Tal Date: Fri, 14 Aug 2015 15:24:31 +0300 Subject: [PATCH] Adding support for configurable session expiration time --- config/env/default.js | 2 ++ config/lib/express.js | 3 +++ 2 files changed, 5 insertions(+) diff --git a/config/env/default.js b/config/env/default.js index 105aa154..cc09ea42 100644 --- a/config/env/default.js +++ b/config/env/default.js @@ -10,6 +10,8 @@ module.exports = { port: process.env.PORT || 3000, templateEngine: 'swig', // Session details + // session expiration is set by default to 24 hours + sessionExpiration: 24 * (60 * 1000), // sessionSecret should be changed for security measures and concerns sessionSecret: 'MEAN', // sessionKey is set to the generic sessionId key used by PHP applications diff --git a/config/lib/express.js b/config/lib/express.js index ca4313eb..9e2bfe03 100644 --- a/config/lib/express.js +++ b/config/lib/express.js @@ -115,6 +115,9 @@ module.exports.initSession = function (app, db) { saveUninitialized: true, resave: true, secret: config.sessionSecret, + cookie: { + maxAge: config.sessionExpiration + }, key: config.sessionKey, store: new MongoStore({ mongooseConnection: db.connection,