Logout when the user close the tab
<p>On my Django site, I want to logout from the site automatically when I close the tab or browser. I mean when I close the site by closing the tab instead of using logout button, after entering the URL again, I want to see that the user has already logged out from the site to force the user to enter username and password again. </p>

<p>Is there a way to handle closing the tab in JQuery? </p>

<p>Thank you in advance.</p>

<p>Edit: onunload &amp; onbeforeunload events cause to logout the user when also reloading the page. </p>