Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi

I have one log out button on the click of it i have called formsauthentication.signout method its works fine but when i closed Browser tab without pressing Logout button user session stays alive. what i want to generate that button event or call formsauthentication.signout method on closing of browser tab via javascript function any suggestions.I know that i have to call that javascript function in bodyUnload. any body help me what i have to write to generate that button even in javascript i have Tried

var btn = document.getelementByid("<%LogoutButton%">
btn.click();

but its not working. any suggestions
Posted

1 solution

XML
var btn = document.getelementByid("<%LogoutButton%">
btn.click();

This does initiate but by the time Click is called, the form is already closed and thus the event is not executed. Thus, it's not working. Try to put a delay such that onclick event can occur and see. Though, I would like to inform, handling browser close is not easy and full proof.

Also, instead of calling click, try to call a XMLHttpRequest and try to signout.

BTW, session and forms authentication - Both are different.
 
Share this answer
 
Comments
Mahendra.p25 24-Mar-11 1:45am    
Thanks sandeep

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900