简体   繁体   中英

Server-side Blazor get auth expiration

I have a cookie based authentication in a server-side Balzor application.

I would like to show the user a popup when there is 5 minutes before their authentication expires.

Is the only way to keep track of the cookie timestamp through javascript or can I use something in asp.net core 3 authentication or is there possibly some other way?

Thanks in advance!

Instead of notifying users about their login session, you can keep session alive in asp.net core:

services.ConfigureApplicationCookie(config =>
{
    config.SlidingExpiration = true;// Add this
    config.ExpireTimeSpan = TimeSpan.FromMinutes(15);
    config.Cookie.HttpOnly = true;

});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM