<script>
window.onbeforeunload = function(){
$.ajax({
type: "GET",
url: "page/out.php"
});
}
</script>
I am trying to destroy session if user pressed (X) in tab
I used the onbeforeunload
event but the session is destroyed each time when I click the "Submit" button in the form or just refreshing the page
</div>