session
session copied to clipboard
Pass new session as extra param to Session reload and regenerate callbacks
Why? The scope calling regenerate (or reload) does not necessarily want or need to know what a req is. Passing the new session object as a callback parameter allows the callback to regenerate or resave then make changes without knowing about req. Example:
session.regenerate((err, newSession) => {
if(err) return next(err);
session.justRegenerated = true; // Just an example.
});
I specifically wanted this to Session.regenerate but added to Session.reload too for consistency. Might also want it in Session.save callback but that seems to require change in the behaviour of plugins so I gave it a pass.
@import-brain, @dougwilson Any chance merge?