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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Clear Session Variable via Hyperlink

Status
Not open for further replies.

123ASP

MIS
Nov 2, 2002
239
US
I am trying to clear session variable once a user click on a link outside my site. This is the code but use can still click on back arrow on the browser and still view/edit the site. how can I remove the session once the user click on the link.

<asp:HyperLink id=&quot;HyperLink1&quot; NavigateUrl=&quot; target='_self' OnClick=&quot;ClearSession&quot; runat=&quot;Server&quot;> Yahoo</asp:HyperLink>


Sub ClearSession(Source As Object, E As EventArgs)
Session.Abandon()
end sub

thanks
Al
 
You can try to change the hyperlink into a linkbutton and use the following code
Code:
Private Sub lnkButton_Click(sender as Object, e as EventArgs) Handles lnkButton.Click
 Session.Abandon()
 Response.Redirect(&quot;[URL unfurl="true"]http://www.yahoo.com&quot;)[/URL]
It will work for sure!

[morning]
 
Thanks Joulius,

I am getting an error Handles cause require a WithEvents variable. I am not using code behind so where shall I declare the variable in page_load or else where
Thanks
Al
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top