0

I want to check my registers users active or not for that users came to my index.php page i want to insert the table through session user1 is active and same time without logout user1 is closing the browser tab or browser the table should be update user1 is inactive.

Advice me it's possible to do that, can do mean please help me how to do that part or is there any possible way to do that same function.

Jerad
  • 213
  • 5
  • 25

3 Answers3

0

Yes, it is quite easy to implement this. You can make an AJAX call on onbeforeunload() and then handle that AJAX request and update the status of the user in the table. You can get the user from SESSION[] array.

Ankit Agrawal
  • 596
  • 5
  • 12
0

You can use onbeforeunload event handler in Javascript.

More details here

Vinay Gayakwad
  • 526
  • 4
  • 10
  • 20
  • this function is working while closing the tab and browser database table update also working but one issue is when refresh the page also that script trigger the sql how to stop that – Jerad Feb 20 '19 at 11:10
0
 var inFormOrLink;

            $(window).bind("beforeunload", function() {
                return inFormOrLink ? "Do you really want to close?" : null;
            })

this code is working but this message is not coming ('Changes you made may not be saved') this message only coming why is that?

Jerad
  • 213
  • 5
  • 25