Cookie is a executable program, which the server posts to client machines but what is the timeout of the cookie
Learning the concept of cookies so this question comes to my mind.
CodePudding user response:
For ASP.NET Core by default cookie set with Append(string, string)
or Append(String, String, CookieOptions)
with default options will result in so called session cookie which will expire once you log off or close the browser.
app.MapGet("/api/ttt", (HttpResponse resp) =>
{
resp.Cookies.Append("testcookie", "val");
resp.Cookies.Append("testcookie1", "val", new CookieOptions());
return new { Test = "ok" };
});
You can control the cookie expiration by setting MaxAge
or Expires
properties on CookieOptions
.
Note that ASP.NET Core has several specific cookies (like auth cookies) which can have their own default lifetimes.
CodePudding user response:
30 minutes For more details, you can check in below link https://learn.microsoft.com/en-us/dotnet/api/system.web.security.roles.cookietimeout?view=netframework-4.8.1