sails: config.session.cookie.rolling not work when session is not modified during a request
Sails version: 0.12.14 Node version: v9.2.0 NPM version: 3.10.10 (npm3) DB adapter name: sails-mysql for model storage and connect-redis for session storage DB adapter version: 0.11.5 (sails-mysql) and 3.3.2 (connect-redis) Operating system: CentOS 7 x86-64
What happened to my app?
Dear developers,
I was configuring the session of my app and found the auto rolling feature for sessions seems to not work, that is, the session.maxAge of the corresponding request will not be auto reseted if session is not modified.
I have read https://github.com/expressjs/session#cookie carefully but I still can not figure out what is wrong with my config/local.js and my app 😦 .
For some political reason I cannot access to http://bit.ly/sails-issue-repro so I am not sure whether my issue reproducing repo meets your requirements 😦 .
My configurations
Session storage adapter: connect-redis
Redis version: 4.0.6
config/local.js:
module.exports = {
port: 80,
session: {
adapter: 'connect-redis',
host: '127.0.0.1',
ttl: 7 * 24 * 3600, // One week
db: 0,
prefix: 'sess:',
cookie: {
resave: false,
maxAge: 7 * 24 * 3600 * 1000, // One week
rolling: true,
saveUninitialized: false
},
routesDisabled: ['GET /js/*', 'GET /css/*', 'GET /images/*']
},
models: {
migrate: 'safe',
connection: 'localDiskDb'
// connection: 'mysql'
}
}
Issue reproducing repository
sails-issue-repro-session-rolling
Issue reproducing steps
- Run app.
- Visit http://localhost/test/wr?str=rua and check the expiration date of the session cookie on a browser. This request will modify
sessionand therefore thesessionis initialized and will be saved. - Wait for some time, say, 1 minute.
- Visit http://localhost/test/rd and check the expiration date of the session cookie on a browser again. This request will not modify
session.
You will find the expiration date of the session cookie will not be reset until you modify session by visiting http://localhost/test/wr?str=someDifferentString again.
Finally
The following configurations cannot help, too.
// config/local.js
module.exports = {
port: 80,
session: {
adapter: 'connect-redis',
host: '127.0.0.1',
ttl: 7 * 24 * 3600, // One week
db: 0,
prefix: 'sess:',
cookie: {
resave: true, // Hey, there
maxAge: 7 * 24 * 3600 * 1000, // One week
rolling: true,
saveUninitialized: false
},
routesDisabled: ['GET /js/*', 'GET /css/*', 'GET /images/*']
},
models: {
migrate: 'safe',
connection: 'localDiskDb'
// connection: 'mysql'
}
}
or
// config/local.js
module.exports = {
port: 80,
session: {
adapter: 'connect-redis',
host: '127.0.0.1',
ttl: 7 * 24 * 3600, // One week
db: 0,
prefix: 'sess:',
cookie: {
resave: true, // Hey, there
maxAge: 7 * 24 * 3600 * 1000, // One week
rolling: true,
saveUninitialized: true // Hey, there
},
routesDisabled: ['GET /js/*', 'GET /css/*', 'GET /images/*']
},
models: {
migrate: 'safe',
connection: 'localDiskDb'
// connection: 'mysql'
}
}
That’s all. I suspect this is a bug, probably. I hope some would help me with this issue very soon XD.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (3 by maintainers)
Still waiting ( ͡° ͜ʖ ͡°)✧