This weekend I was doing some work on my pet little portal project and needed to create a logout link where the user can logout or sign-out. The membership interface did not have any logout method and abandoning the session did not help either. Although the LoginStatus control did log the user out, I needed to do this programmatically and not through the UI.
I searched the web with many different keywords hoping to find an answer but with no avail. I knew it could be done as other products have the feature so I jumped into MSDN to find the answer, after a few hours of my life I found one line of code that does it:
FormsAuthentication.SignOut();
The System.Web.Security.FormsAuthentication class can be really useful when customising and controlling authentication.