Avatar of Wicked-Websites
Wicked-Websites
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

Run Log Off html page when user closes the browser?

Hey,

I have a website, with login / logout working, there is a list of logged on users.

basically when they log on using php online is set to yes in a database, and when they log off online is set to no... however if they shut the browser without logging off correctly then online stays as yes...how can I get a script that sets online as off when they click X

I've tried the code attached, however that doesnt work and i dont know enough about cron jobs etc to know if that would work

<body onUnload='spawn("../admin/scripts/logout.php")'>
<script language="Javascript">
function spawn(page) {
window.open(page,"","left=5,top=5,height=300,width=150,status=no,toolbar=no,menubar=no,scrollbars=no");
}
</script>

Open in new window

JavaScriptPHP

Avatar of undefined
Last Comment
Wicked-Websites

8/22/2022 - Mon