Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FormsAuthentication.Logout()

Status
Not open for further replies.

thedman00

Programmer
Jun 11, 2003
46
AT
I'm using form authentication. The user logs in ok and then clicks logout which calls the formsauthentication.logout which successfully logs them out. Then if the user logs back in without closing the browser and clicks logout it doesn't clear the authentication (log them out). any assistance would be great.
 
You should be using the method when you log the user in to create a persistent cookie...this should prevent them from appearing to be logged in when clicking Back.
 
I tried changing it but it still doesn't work. For some reason the first logout works but if they login again the logout doesn't.
 
Have you set the authentication method to "forms" and named a persistent cookie in your web.config file?
 
I figured out the problem. When the user clicks logout they are redirected to a page which on load calls the formsauthentication.logout(). The problem is that after the first time it just pulls up the cached page. If i do a hard refresh by holding down control and hitting F5 it works. So the question now is how do I keep it from caching the page?
 
I thought you could set the persistent cookie in the RedirectFromLoginPage parameter
 
You can tell the .NET Framework to persist your cookie in the method signature, but you also need to define what the cookie's name is and explicitly set your authentication mode to "forms" in web.config.
 
Yeah I did set the authentication to forms in the web.config. Is there a way to tell the browser not to cache a page?
 
what you might want to try is have a button in the same web form as your other code, that when clicked fires the OnClick event that executes FormsAuthentication.SignOut(). This should cause a postback, and prevent any unnecessary caching.
 
You're probably right. I'll give that a try. Thanks for the prompt responses
 
Good luck! Have fun programming with ASP.NET!

---------------------------------------------------
Jason Salas, MBA, MCP
Web Development Manager
Pacific Telestations, Inc. (dba, "KUAM")
URL: President, .NET User Group of Guam
URL: Mailto: jason@kuam.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top