'Automatic Logout On Close Tab/Browser - Blazor Server Side

Im Working on a Blazor Server Side app with Identity, and i want to end session when user close Tab / Browser, i try using the following

services.AddSession(options =>
        {
            options.IdleTimeout = TimeSpan.FromSeconds(300);
            options.Cookie.IsEssential = true;
            options.Cookie.HttpOnly = true;
            options.Cookie.Expiration = DateTime.MaxValue;
        });

But it didn't work. I think It's probably a misunderstanding of concepts from my part, would appreciate any help! Or if they need more data to Provide, just tell me!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source