Solve issue with redirects

When changing the session and then calling `res.redirect(...)`
express-session calls `res.write`, which flushes the headers and causes
the browser to start redirecting without waiting for the store to finish
saving.

express-session should not send the headers until the store finishes
saving.

I patched it for now with a hack. It probably requires a more robust
solution.