Possible Duplicate:
How we call logout servlet on browser close event
I want my site to automatically logout user when the browser closes. I use onunload in javascript. Now, my problem is it always logout the user everytime the user navigates to other page. What I want is just to logout when the browser closes.
Here's my code:
<script type="text/javascript">
window.onbeforeunload = confirmExit;
window.onunload = logout;
function confirmExit() {
return "Are you sure you want to leave?";
}
function logout() {
window.location = '<?php echo WEBSITE_URL ?>?logout=true';
}
</script>
Hope someone will help me ASAP!