I can't seem to find an answer to this seemingly simple question.
What is the difference between using the first or the later? Why would I use the first?
On MSDNAA I find the following regarding Formsauthentication.setCookie():
Creates an authentication ticket for the supplied user name and adds it to the cookies collection of the response, or to the URL if you are using cookieless authentication.
Regarding Session:
ASP.NET session state enables you to store and retrieve values for a user as the user navigates the different ASP.NET pages that make up a Web application. HTTP is a stateless protocol, meaning that your Web server treats each HTTP request for a page as an independent request; by default, the server retains no knowledge of variable values used during previous requests. As a result, building Web applications that need to maintain some cross-request state information (applications that implement shopping carts, data scrolling, and so on) can be a challenge. ASP.NET session state identifies requests received from the same browser during a limited period of time as a session, and provides the ability to persist variable values for the duration of that session.
I'm especially interested in why I'd use formsauthentication.SetAuthCookie when I use a session cookie to check if the user is correctly logged in. E.g.:
if(Session["LoggedIn"] != null) {
...Do something here that only logged in users are allowed to do...
}
It seems that I've found my answer on the asp.net site:
http://forums.asp.net/t/1587046.aspx/1#4012585
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With