Skip to content
This repository was archived by the owner on Aug 30, 2021. It is now read-only.

Commit 5d20988

Browse files
committed
adding support for configurable session cookie parameters for express
1 parent f67b7d9 commit 5d20988

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

config/env/all.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,31 @@ module.exports = {
88
},
99
port: process.env.PORT || 3000,
1010
templateEngine: 'swig',
11+
12+
// The secret should be set to a non-guessable string that
13+
// is used to compute a session hash
1114
sessionSecret: 'MEAN',
15+
16+
// The name of the MongoDB collection to store sessions in
1217
sessionCollection: 'sessions',
18+
19+
// The session cookie settings
20+
sessionCookie: {
21+
path: '/',
22+
httpOnly: true,
23+
// If secure is set to true then it will cause the cookie to be set
24+
// only when SSL-enabled (HTTPS) is used, and otherwise it won't
25+
// set a cookie. 'true' is recommended yet it requires the above
26+
// mentioned pre-requisite.
27+
secure: false,
28+
// Only set the maxAge to null if the cookie shouldn't be expired
29+
// at all. The cookie will expunge when the browser is closed.
30+
maxAge: null
31+
},
32+
33+
// The session cookie name
34+
sessionName: 'connect.sid',
35+
1336
assets: {
1437
lib: {
1538
css: [

config/express.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,9 @@ module.exports = function(db) {
9393
store: new mongoStore({
9494
db: db.connection.db,
9595
collection: config.sessionCollection
96-
})
96+
}),
97+
cookie: config.sessionCookie,
98+
name: config.sessionName
9799
}));
98100

99101
// use passport session

0 commit comments

Comments
 (0)