Issue with multiple session.save() calls.
Hi there,
Thank you for this awesome library. ❤️
Would it be possible to support multiple session.save() calls? My use case is for saving the session as soon as possible to avoid loss of data because of exceptions later on in the code. I am trying to use this library as a connect middleware with next-connect and the code to update the session spans multiple middlewares in different files.
Currently it sets the set-cookie header multiple times with the same cookie name, which can have unpredictable behaviour as these headers might get re-ordered, or even dropped as per this stack-overflow comment. Even when running locally, it failed a few times with session not having the updated value - which prompted me to search in stackoverflow if this could cause any issues.
I did solve the issue in my code by making sure only one session.save call gets invoked for any given execution path - still I think it'll be nice to support this by the library itself - if it's not too much to request.
I took a quick look at the source code to see how it's handled now, but I'm not sure I'm confident enough to for a PR.