Click here to Skip to main content
15,896,269 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
any suggesition will be appriciated
in login form When user press login Button, at same time also a sql db tbl column is updated. Table column is a Bit data type. So when user press login Button, column is updated to True. That would be look like that user is login at the moment. But, when user is close Browser, database column will still have value True. Any idea how to update table value even after closing browser if is it possible??
Posted

Basically, you can't - there is no reliable method that works for all browsers, and even if there were, that wouldn't help if there was a power cut, for example, or the browser is closed with "End Task".

The best way to do this is to kill the DB when the Session expires: that way it's independent of what happens at the client. See Session-State Events[^] and look at the Session_OnEnd event.
 
Share this answer
 
The web is stateless so your server-side code doesn't know if the user is there or not (they could be looking at your site, they might have moved to another site, they might have closed their browser, they might just be away from their desk...you just don't know), so there is no point doing what you're trying to do.

If you want to track who is on-line then the best you can really do is record every time someone accesses a page and assume those who haven't accessed a page for a while is no longer active.

Tracking which users are currently active | The ASP.NET Forums[^]

Things you shouldn't spend time doing | The ASP.NET Forums[^]
 
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