Sharing session store between multiple session instances doesn't work
- Dominant language
- JavaScript
- Stars
- 6.4k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
In my code I've two session instances with different cookie options (domain, path). Those two express-session instances share same RedisStore with different cookie options. However it does not seem to matter which express-session instance is used, the later instantiated cookie options will be applied.
To be concrete, I wrote test case to show what I expected the results would be, but currently this test case fails:
```
it('should use own session opts with shared store', function(done){
// The beef: sharing same store instance. Replace with null and the test will pass
var store = new session.MemoryStore()
var app = express()
.use('/path1', createSession({store, cookie: { path: '/path1' }}))
.use('/path2', createSession({store, cookie: { path: '/path2' }}))
.use(function(req, res, next){
res.end()
})
request(app)
.get('/path2')
.expect(shouldSetCookieWithAttributeAndValue('connect.sid', 'Path', '/path2'))
.expect(200, function (err, res) {
if (err) return done(err)
request(app)
.get('/path1')
.expect(shouldSetCookieWithAttributeAndValue('connect.sid', 'Path', '/path1'))
.expect(200, done)
})
})
```
Should it work if one store is shared between multiple session/cookie options? Or is this just wrong usage?
Contributor guide
Assessment
This issue has not been assessed yet.