-1
Good guys blz, I wanted to know how to call an event when I close tab or browser and when to close I wanted to update mysql ex: logged in=1, then when it closes update to log in=0
-1
Good guys blz, I wanted to know how to call an event when I close tab or browser and when to close I wanted to update mysql ex: logged in=1, then when it closes update to log in=0
1
You could use a beforeunload
to call your event before the window closes, although it is not compatible with some browsers.
$(window).on('beforeunload',function(){
//meu evento
});
An alternative solution would be to send a POST warning to the server that the user is still online, such as:
var online = setInterval(function (){
//fazer teu post aqui
}, 60000);
So every 60 seconds the user will be updated with the current time, then to check if he is online or not just check if the last time he was seen has more than 60 seconds.
Thanks friend helped me a lot.
Browser other questions tagged php javascript jquery mysql
You are not signed in. Login or sign up in order to post.
Why not use the
SESSION
of PHP?– João Pedro Henrique
How would you when to close the tab or browser destroy Session ?
– Psicodelico ॐ
Can use
beforeunload
with javascipt, although not working in 100% of situations.– João Pedro Henrique