Does FormsAuthentication.SetAuthCookie() make a session based cookie?

后端 未结 2 788
渐次进展
渐次进展 2021-01-11 20:42

Ok I\'m rather confused, does FormsAuthentication.SetAuthCookie() in asp.net create a session based cookie or not? From what I gather to put something in a session you would

相关标签:
2条回答
  • 2021-01-11 21:15

    I'm not sure exactly what you're asking, but if your question is how can you access Session["userAge"] without an auth cookie, the answer is because it's a separate entity from the session.

    The auth cookie (default name .ASPXAUTH) is created before the session is even started so it can't be based on the session.

    0 讨论(0)
  • 2021-01-11 21:28

    This is a common confusion. Session and FormsAuthentication are two separate concepts - they have independent timeouts and independent cookies (or no cookies if you're using Cookieless sessions.)

    Session on the server is identified by a unique cookie that is created even for anonymous users. This cookie holds a SessionID that has nothing to do with FormsAuthentication.

    The FormsAuthentication cookie contains a number of things, the most important of which is the authentication ticket. This ticket is an encrypted bit of info that identifies the user against the login credentials supplied. There is a great step-by-step flowchart and explanation of what's in a ticket in this MSDN article.

    0 讨论(0)
提交回复
热议问题