I am creating an application where users cannot attempt multiple logins. If a particular user logs in, my database flag value becomes set to 1 that means no other member who has the same username and password can login.
If a user signs out my database flag value is set to 0. That’s all working fine but now I have one different problem that is when a user suddenly closes the browser without logout page or session is timeout then automatically the database flag value should be set to 0.
I am searching about this some articles said it can happen using global.asax file. I tried it but nothing happend so far. Please can you help me?
The only safe way to detect that a user has closed the browser window is through a heartbeat. That is, the browser keeps sending requests to the server to let it know it’s still alive. Since ASP.net keeps track of the sessions, it will call your session end handler after it detects inactivity.
Therefore, if you set your session timeout to be one minute, and keep sending requests every 45 seconds, your session end handler will be called with at most one minute delay