Community has raised need for having easier way to sync session state with storage.
Background
Currently session middleware is only responsible for reading data from store and initiating session in request scope. In turn it is not responsible for writing updated session back into session store. State persistence needs to be dona manually through manual use of SessionStore.
Options
Two potential options have been named:
-
separate write middleware that detects session state change and performs state dump into session store
-
extensions to existing middleware that utilises response hooks and performs state dump into session store just before response flow is about to end - based on how express session module works
Second one is preferred cause it offers all-in-one solution which does not require other application middlewares to be mindful of session writing middleware to not break the middleware invocation chain.
Community has raised need for having easier way to sync session state with storage.
Background
Currently session middleware is only responsible for reading data from store and initiating session in request scope. In turn it is not responsible for writing updated session back into session store. State persistence needs to be dona manually through manual use of
SessionStore.Options
Two potential options have been named:
separate write middleware that detects session state change and performs state dump into session store
extensions to existing middleware that utilises response hooks and performs state dump into session store just before response flow is about to end - based on how express session module works
Second one is preferred cause it offers all-in-one solution which does not require other application middlewares to be mindful of session writing middleware to not break the middleware invocation chain.