Is there a way to call a function when the php-page gets closed?
I am saving the online/offline status in my MySQL db.
With my function
Users::isOffline(Users::getUserName())
I'm writing "offline" into the db.
Now I want to call this function when someone is closing the page with the close button.
I've tried this:
<script language="JavaScript" type="text/javascript">
window.onbeforeunload = confirmExit;
function confirmExit()
{
var offline= <?php echo Users::isOffline(Users::getUserName())?>;
}
</script>
But then, the function gets called when the php-page is loaded....
Any ideas? :)