Click here to Skip to main content
14,971,754 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
If anybody closed window without clicking on logout then how to clear session?
Can anybody tell me?
Bcoz I want to set status in database on login and logout button.
Posted

Hi,
use
Session.Clear()
before closing window
   
Comments
Dipali_Wagh 11-Jul-13 7:59am
   
but where to close?
if somebody directly closed window, then?
C#
HttpContext.Current.Session.Abandon();
Session.Abandon();
Session.Contents.Clear();



write this in void Session_End(object sender, EventArgs e) method in global.asax file
   
Comments
Dipali_Wagh 11-Jul-13 8:01am
   
I want to set status in login table as 1 when user logged in.
And want to set it as 0 when user logged out.
so that if one user is logged in another user cant access it.
but if without logout if somebody closed window, then how to set that status as 0.
plz tell me how to achieve this?
manjunathmk 20-Jul-13 3:05am
   
http://forums.asp.net/t/1887726.aspx/1?How+to+execute+code+behind+when+user+closes+browser+window+
if user close browser then session will be null automatically if user close tab then

http://www.google.co.in/#biw=1024&bih=677&sclient=psy-ab&q=clear%20session%20using%20javascript%20in%20asp.net&oq=&gs_l=&pbx=1&bav=on.2,or.r_qf.&bvm=bv.48705608,d.bmk&fp=454708d46e718598&pf=p&pdl=300
   

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