i use in my app authentication type called application cookie i want when the user close the browser the cookie must be expired auto
again the user try open the application
it is supposed the application ask the user about username and password
how can i solve that ?
by the way, i use .net framework standard mvc
Nikunj SatasiyaPosted Jul 24, 2024, 8:57 AM
Mohamed,
In order to ensure that the authentication cookie in your ASP.NET MVC application expires when the user closes their browser, you need to configure the cookie authentication to use a session-based cookie rather than a persistent cookie. A session cookie is deleted when the browser session ends (i.e., when the browser is closed).
Here’s how you can configure this in an ASP.NET MVC application using the .NET Framework.
In your
Startup.Auth.csfile, which is typically found in theApp_Startfolder of your ASP.NET MVC project, you need to modify the settings in theCookieAuthenticationOptionswhen configuring theUseCookieAuthenticationmiddleware.Here's an example of how you can configure it
Important points:
nullto make the cookie a session cookie, which means it will expire automatically when the browser is closed.Arthur LandryPosted Dec 28, 2024, 2:52 AM
Thanks for your sharing. This is what I am looking for.
Mohamed abdelkaderPosted Jul 24, 2024, 12:08 PM
thanks engineer Nikunj but i don't find CookieExpiration = null in new CookieAuthenticationOptions
it does not appear as property related to this class