Feature Request - Optional flag to skip automatic session save at the end of HTTP response
- Dominant language
- JavaScript
- Stars
- 6.4k
- Forks
- 1k
- PR merge metrics
- No merged PRs in 30d
Description
When using `express-session` with `passport.js` and `connect-redis` store, logging in a user with `req.login()` triggers an immediate save of the session to the redis store. At the end of the HTTP request, `.save()` is called again, resulting in a redundant request to the redis server.
It would be nice if the session could take into account an optional flag, `skipNextSave`, which would prevent the automatic save at the end of the request cycle if it has been set. This flag should be then cleared after being checked, allowing subsequent saves to occur normally.
Proposed Implementation:
```
function shouldSave(req) {
if (req.session.skipNextSave) {
delete req.session.skipNextSave;
return false;
}
// ....
}
```
Contributor guide
Assessment
This issue has not been assessed yet.