Concurrency Metering
-
How can I keep track of the number of online users to implement concurrency metering? So far I have implemented as follows: When a user logs in, I add an entry to a Status table in the database and store a cookie in his machine.Every time he refreshes his browser, it checks if the cookie exists.If it doesnt exist, it treats it as a new login and updates the status table. Now I need to remove/decrement the status by 1 when the user logs out. I included this code in Session_End. But there is a problem, I need to call this fucntion only when the user closes his browser. If the user leaves his system idle or refreshes his browser again, Session_End is called twice and the status is decremented by 1 two times, which is incorrect. How should I implement concurrency metering? Is there any other way other than using session, since most users would probably log out by closing the browser instead of clicking the Log Out button.