Clearing FormsAuthentication cookie manually

T

tshad

Is there a way to manually clear the FormsAuthentication cookie?

I want to be able to clear the cookie before going to a specific page to
force the logon page to be called before the page.

Thanks,

Tom
 
J

Joe Fallon

I have a sign out button coded like this:

Private Sub btnSignOut_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSignOut.Click
Session.Clear(HttpContext.Current.Request.Cookies("ASP.NET_SessionId").Value)
System.Web.Security.FormsAuthentication.SignOut()
HttpContext.Current.User = Nothing
Response.Redirect("~/Login.aspx", True)
End Sub
 
T

tshad

Joe Fallon said:
I have a sign out button coded like this:

Private Sub btnSignOut_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSignOut.Click

Session.Clear(HttpContext.Current.Request.Cookies("ASP.NET_SessionId").Value)
System.Web.Security.FormsAuthentication.SignOut()
HttpContext.Current.User = Nothing
Response.Redirect("~/Login.aspx", True)
End Sub

Looks like what I need.

Thanks,

Tom
 
T

tshad

Joe Fallon said:
I have a sign out button coded like this:

Private Sub btnSignOut_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSignOut.Click

Session.Clear(HttpContext.Current.Request.Cookies("ASP.NET_SessionId").Value)
System.Web.Security.FormsAuthentication.SignOut()
HttpContext.Current.User = Nothing
Response.Redirect("~/Login.aspx", True)

BTW, what does the following do?:

Response.Redirect("~/Login.aspx", True)

What is the tilde for?

Thanks,

Tom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top