I need to clear the session variables when the tab is closed but I could not find any solutions so far. The closest I have got is by using the \"onbeforeunload\" function is
Unfortunately, there is no way to prevent page refresh (caused by form submit or any other navigation) from calling "onbeforeunload".