session icon indicating copy to clipboard operation
session copied to clipboard

Max age resetting after response

Open jonathanong opened this issue 11 years ago • 8 comments

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.

   // 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);
      });
    };

jonathanong avatar Feb 16 '14 01:02 jonathanong

It should only grow (i.e. get reset) when rolling sessions is enabled.

dougwilson avatar Jan 05 '15 20:01 dougwilson

Fixing this would require a major version bump, sadly :(

dougwilson avatar Jan 05 '15 20:01 dougwilson

Fixing this would require a major version bump, sadly :( dougwilson added this to the 2.0.0 milestone on 5 Jan 2015

express 4 is out now, what's the reason why the bug is not fixed yet?

timaschew avatar Aug 30 '16 09:08 timaschew

@timaschew , I'm unsure what the major version of this module has to do with the version of Express.

dougwilson avatar Oct 26 '16 20:10 dougwilson

@jonathanong Just wondering this is not a bug. Once client requests and is being active, to keep the session interactive, maxAge of cookie is been refreshed with each response as cookie expiry disconnects client from session with ongoing interactions.

cc @dougwilson

HarshithaKP avatar Nov 25 '19 08:11 HarshithaKP

Hi @HarshithaKP I have never heard of the issue you are describing. Can you provide code and steps to reproduce the issue you are referring to?

dougwilson avatar Nov 25 '19 15:11 dougwilson

@dougwilson Sorry that assumption was a mistake, I will go through the issue again and get back to you.

HarshithaKP avatar Nov 26 '19 05:11 HarshithaKP

This issue is not prioritized and has not had meaningful activity for some time. It can be re-opened when a PR is raised, if needed.

davidmashe avatar May 11 '20 01:05 davidmashe