Allow maxAge 0 and make defaultMaxAge a variable to create a non-persistent cookie #58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to the following PR.
#55
Here is the outline of changes.
maxAge
0 when saving a redis store.defaultMaxAge
a variable and allow to change this value from outside.Why allow MaxAge to be 0?
When setting cookie, by not setting a MaxAge, we can make a one-time cookie and user loses authentication state after closing the browser. And then, user will open website again, the login state would not be persisted and we can prompt to login again.
But if redis TTL is set to zero, server loses the authentication information while user is staying in the browser, and the user's login status will be disappeared
I think it's not uncommon to use redis with some TTL and to set the session's MaxAge to 0, which is required for my product indeed.
There is already a
defaultMaxAge
property, but nowmaxAge
is not allowed to be 0, sodefaultMaxAge
has no chance to be used.But this approach is flexible, allowing maxAge to be 0, we can set different expiration for session and redis.
Once I'd like to give arguments to
Save
function, but this is an implementation of Interface, so we can't change function structure.So I accomplish this by changing defaultMaxAge from outside. With this approach we can realize this use case without breaking the implementation of interface.