Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

How to expire the session immediately?

I want to do these: if user clicked the Sign Out button, the session abandon and the login page displays. If the user clicks the browser Back button, it won't show the previous page. It shows only the login page. How does is work? Thanks.
DanYeung
[266 byte] By [Acceris] at [2007-11-11 8:46:08]
# 1 Re: How to expire the session immediately?
Assuming you're using Forms Authentication, you should do this when the user logs out:

' Imports System.Web.Security
Session.Abandon()
FormsAuthentication.SignOut()
Response.Redirect("~/login.aspx")

In order to prevent the user from using the Back button at that point, you must configure IIS to expire content immediately: http://www.microsoft.com/windows2000/en/server/IIs/htm/core/iipswwws.htm

I know of no way to make the Back button take the user to the login page unless that's the page he came from.
Phil Weber at 2007-11-11 23:13:02 >