Click here to Skip to main content
15,888,521 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
how to remove user online from database after session end asp?
Posted

Do you REALLY want to remove the user from the database? You have to ask a more precise question. What I think you really want to do is remove the user's logon status from the database. For that, you would need to do something like this:

0) Add a DateTime column to the user logon status table.

1) Every time the user does something on the web site, update that column with the current date time.

2) Create a job in sql server based on a time interval (maybe 30 minutes) that scans that column for a last-update time that exceeds 30 minutes. If it finds one, remove that user's logon status from the table.

3) (Optional) Before the user is allowed to do anything, the code checks the logon status to see if they are still considers to be logged on. If so, they are allowed to proceed. If not, it asks them for credentials again.

4) You can also put code into the web site that contributes to the system.
 
Share this answer
 
Comments
Tech Code Freak 21-Aug-11 9:48am    
My 5! + Bkmrkd
fjdiewornncalwe 21-Aug-11 18:47pm    
This is how an enterprise level application typically does this. +5
You add global.asax file in your project. and use session_end event write code for if sessiion end then remove your database login status and session_start event write code for insert in database login start.
 
Share this answer
 
Comments
fjdiewornncalwe 21-Aug-11 18:48pm    
That won't catch all the sessions that end abruptly. You still have to scrub the session data in the database how JSOP describes to catch them all.

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