In ASP.NET, Session_End will be fired when the Session is time out then I can guess the user has left or close the Browser window in this method.
But there is some delay till time out, is there any better solution?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Since there are many things that can interrupt a user’s visit like a lost connection, or a browser crash; you should rely on the the client to tell the server “Hey I am still here.” and assume they left when they stop doing so that rather than have the client tell the server they left.
To accomplish this, you can use what’s known as the “Heartbeat”:
http://ajaxpatterns.org/Heartbeat
You can tweak the heartbeat interval so the effect can be more immediate. Doing that you can also tweak what you consider “user activity.” Relying on functions fired
onunloadwill cause users who left their computer but didn’t close their browser window appear to be “active.”