Skip to content

Node.js based forum software built for the modern web

Fixing null ttl issue for MongoSession

Dominic Lennon3f116e76362e
diff --git a/src/database/mongo.js b/src/database/mongo.js
index c9323df23a..3a3331e900 100644
--- a/src/database/mongo.js
+++ b/src/database/mongo.js
@@ -123,15 +123,16 @@
module.initSessionStore = function (callback) {
var meta = require('../meta');
var sessionStore;
+
+ var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 0);
+ var ttlSeconds = 1000 * (parseInt(meta.config.loginSeconds, 10) || 0);
+ var ttl = ttlSeconds || ttlDays || 1209600000; // Default to 14 days
+
if (nconf.get('redis')) {
sessionStore = require('connect-redis')(session);
var rdb = require('./redis');
rdb.client = rdb.connect();
- var ttlDays = 1000 * 60 * 60 * 24 * (parseInt(meta.config.loginDays, 10) || 0);
- var ttlSeconds = 1000 * (parseInt(meta.config.loginSeconds, 10) || 0);
- var ttl = ttlSeconds || ttlDays || 1209600000; // Default to 14 days
-
module.sessionStore = new sessionStore({
client: rdb.client,
ttl: ttl