How to check if the user is currently online?

Asked

Viewed 144 times

1

The thing is, I made a system where the administrator can see the online users at the moment and move them. So far so good, I created a variable in the table user in mysql that becomes TRUE when the user logs and FALSE when it depresses, the problem is if the user closes the page without undoing, because it will be offline but will not update to get the value FALSE in the bank.

Some Suggestion of what I should do?

NOTE: I am developing in ASP Classic

3 answers

0

I had a problem from that time and I did the following: I created a table to inform users who log in to the system (it even serves as an access log). Well, each "logged in", the table receives a record stating date and time, time date of last transaction and browser ID (and login, of course). At the step of each transaction, this record is updated. If the user does not execute a transaction for some time, this is taken offline. If you want to take down the user, simply have each transaction check the signage that can be edited by a moderator...

0

Just register an event to be executed before closing the window and within the event make a call to the server using ajax, for example, and update the table in the database.

window.onbeforeunload = function (e) { 
       // seu codigo aqui 
    };

https://developer.mozilla.org/en/DOM/window.onbeforeunload

  • If the electrical power falls, or stops the system and it is necessary to restart the machine by disconnecting it from the socket, Ajax is called?

0

In your case the most correct way (without gambiarras) is to use the event "Session_onend" of the global file.asa. On the login page create a session variable with the logged in user code (e.g., Session("Userid")) and in the Session_onend event of global.asa, if the session variable exists, update the database with the information that the respective user is no longer logged in. It is also interesting to define a Session.Timeout with the time you want each session to be available.

Note: This is the best solution if the user closes the page without clicking the button to unzip, but it will take a few minutes for the system to understand that the session is over and update the database. Then use it together with the solution you already use today, updating the database when the customer clicks to reload.

This link details your use of the global.asa archive events (in Portuguese): http://www.superasp.com.br/paginas_exibir_details.asp?dep=0,0&id=36

I hope I’ve helped!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.