expressjs / expressjs/session

Max age resetting after response

Open
#2 8 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
6.4k
Forks
1k
PR merge metrics
No merged PRs in 30d

Description

Is there a reason the max age is reset with each response?
I need to be able to see if half of TTL has elapsed. The cookies expiration is being increased but the session still expires at the original max age.

``` JavaScript
// proxy end() to commit the session
var end = res.end;
res.end = function(data, encoding){
res.end = end;
if (!req.session) return res.end(data, encoding);
debug('saving');
req.session.resetMaxAge();
req.session.save(function(err){
if (err) console.error(err.stack);
debug('saved');
res.end(data, encoding);
});
};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.