HorseKing
HorseKing

Reputation: 454

what is the life cycle of FormsAuthentication.SetAuthCookie()?

I have a simple question related to the FormsAuthentication.SetAuthCookie() method.

In my Web.config file, it looks like

<authentication mode="Forms">
  <forms loginUrl="~/Login" timeout="5" slidingExpiration="true" />
</authentication>

In my Login function, it looks like

FormsAuthentication.SetAuthCookie(entity.UserEmail, false);

As we can see, the cookie's expiration time is 5 minutes, and it sets to False for the SetAuthCookie method.

My question is, when user close their page and re-open and visit the same URL right away, is this user still authorized?

I am asking because when I am testing on my local machine, when I close the browser and re-visit right away, I am still logged in.

Problem solved

In order to make it work correctly, I have to close the browser complete. Although I thought I did close it complete, but I didn't. That is the cause of this problem.

Upvotes: 1

Views: 533

Answers (0)

Related Questions