Hello All,
I am creating a Web-Application in which...

'Whenever user logs in I am maintaining his status. So that other can not log in simultaneously using same details.
When user logs out, his status is reseted back, making him able to log in next time.
Above changes are made in login & logout servlets respectively.'

My problem is,
After user logs in & closes the browser at any point, I am unable to change the login status of user as I am unable to call that snippet.

So please somebody help me regarding handling browser closing event.
I tried following code...

<html>
<head>
<script language="javascript">
function onBrowserClose()
// Code ...
</script>
<head>
<body onbeforeunload='onBrowserClose()'>
<a href="test.html">Link</a>
</body>
</html>
But this event is fired even if I follow a link to another page. I want to do my stuff only when browser is closed.

Help me.
Thanks.