How to check if the user is online at the moment?

1

It's as follows, I've made a system where the admin can view the online users at the moment and displace them. So far so good, I have created a variable in the user table in mysql that gets TRUE when the user logs in and FALSE when he flips, the problem is if the user closes the page without moving, since he will be offline but will not do the update for get the value FALSE in the bank.

Any suggestions on what to do?

NOTE: I'm developing in Classic ASP

    
asked by anonymous 26.04.2015 / 00:03

3 answers

0

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

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

link

    
12.05.2015 / 21:10
0

I had a problem from this time ago and did the following: I created a table to inform the users that log in the system (even access log access). Well, at each "login," the table receives a record stating the date and time, the date of the last transaction, and the browser ID (and login, of course). At each transaction step, this record is updated. If the user stays for some time without executing a transaction this is taken as offline. If you want to knock down the user, it is enough that each transaction checks the signage that can be edited by a moderator ...

    
20.08.2015 / 19:09
0

In your case the most correct way (without gambiarras) is to use the "Session_OnEnd" event of the global.asa file. On the login page create a session variable with the logged-in user code (eg, Session ("UserId")) and the global.asa Session_OnEnd event, if the session variable exists, update the database with the information the user is no longer logged in. It's also interesting to define a Session.TimeOut for as long as you want each session to be available.

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

In this link you have more details about your use of the global.asa events: link

I hope I have helped!

    
04.09.2017 / 16:55