BitzArt / Blazor.Cookies

Working with browser cookies in Blazor United
MIT License
31 stars 5 forks source link

Sliding Expiration option for cookie #6

Closed aravindasn closed 4 months ago

aravindasn commented 4 months ago

I am using the BitzArt cookie package in my Blazor project. Is it possible to set sliding expiration on a BitzArt cookie, similar to how it is done with the Microsoft Identity Framework application cookie? Specifically, we would like to renew the cookie expiration date and time. Is this possible?

Thank you, Aravinda

YuriyDurov commented 4 months ago

Hello @aravindasn

This library is about interacting with cookies in general, and this seems more like a topic about authentication rather than cookies themselves.

As for the expiration time, we can see the cookie's expiration when in the context of an http request (Blazor Static SSR or prerendering), but this information is not available in the context of interactive rendering because it's not returned when requesting document.cookie with js. You could store expiration timestamp as a separate cookie though, and use that to re-issue some combination of cookies.

I don't see how this could be implemented directly in Blazor.Cookies, but I believe you could implement sliding expiration as part of your authentication logic.