sidebase / nuxt-session

Nuxt session middleware to get a persistent session per app user, e.g., to store data across multiple requests. The nuxt session module provides the useSession() composable out of the box and sets up API endpoints to interact with your session to make working with sessions feel like a breeze.
https://sidebase.io/nuxt-session/
MIT License
188 stars 19 forks source link

Add rolling option #36

Closed interpretor closed 1 year ago

interpretor commented 1 year ago

Add rolling as an option to be able to force the session identifier cookie to be set on every response. The expiration is reset to the original expiryInSeconds, resetting the expiration countdown.

This is typically used in conjuction with short expiryInSeconds values to provide a quick timeout of the session data with reduced potential of it occurring during on going server interactions.

This should behave similar to the rolling option in express-session middleware.

To implement this, it was necessary to set the expires property of the cookie instead of maxAge, which doesn't affect the current behavior of the middleware.

BracketJohn commented 1 year ago

Hey @interpretor!

Thanks for your contribution ❤️ 💯 This is a great addition (: We'll review and hopefully land it shortly. one quick question: Does this also already address your issue #38?

interpretor commented 1 year ago

Hey @BracketJohn,

you're welcome :) No this doesn't solve #38, it just adds the rolling option without touching the behavior of the module.

valiafetisov commented 1 year ago

@interpretor, sorry that the review is taking longer, I'm currently a bit overwhelmed by the other project, but will come back to you shortly! 🎉

valiafetisov commented 1 year ago

Thanks for the awesome contribution @interpretor 🖤