views:

256

answers:

2

I'm authenticating a user in my application with the method "FormsAuthentication.SetAuthCookie" method, but when I close the browser and reopen it, it is still authenticated, but the session is over already, then my app crashes because it has necessary data on the session to generate the menus.

What I want to do is the following: Create an authentication ticket without create a auth cookie to, whenever the user open the page in a new browser session it will request the login once again.

How can I achieve this.

+3  A: 

Sessions and authentication are different. If you want the cookie to go away when the browser closes then use

FormsAuthentication.SetAuthCookie("username", false);
blowdart
Yep, basically don't give the user the option to create a persistent cookie - if you're using the default Account Controller from the ASP.NET MVC site, then change FormsAuth.SignIn(userName, rememberMe); to FormsAuth.SignIn(userName, false);
Zhaph - Ben Duguid
+1  A: 

Are there other browser windows open? Sometime if there are other browser windows open the cookie will persist.

Chuck Conway