Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello guys.
I want to know how can I have a list of active sessions in asp.net.
In my website when a person login I reserve a session to him/her and then add it to application.
Now I have list of sessions in application but i want to know that if someone close his/her browser how can i understand that he left my website and update the application.
I use sessin_start event handler but it doesent work properly.
please help me.
Thank u.
Posted
Updated 23-Nov-13 6:07am
v2

1 solution

Browser have a event name "beforeunload". When browser is closing that event notify client that browser is closing.
Some problem is there
1. Not all browsers support that event (cross browser issue).
2. When unplanned shutdown (power/software/hardware) failure then this event will not fire.

One way you can achieve that
step 1> When a user login to the system then you increase session counter
step 2> When user logout from the system then you decrease that counter.
step 3> You can store counter in Application level variable. When any client pc shutdown in properly then server may not notify. In that case you can use Session end event to forcely update active session counter.

You need to handle some exceptional scenarios like
1. If user login but instead of logout he shutdown his pc
2. user login the system with multiple browsers simultaneously
3. Web server restarted or application pool recycled.
 
Share this answer
 

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