The website I'm developing for uses a mixture of .NET (aspx), Javascript and jQuery. Looking into a vulnerability that's a result of the following scenario:
While there is a server-side timeout for the user's session after 10 minutes of inactivity, that's still a window in which this vulnerability can be exploited, albeit niche. My first stab at this consisted of:
CODE SNIPPET: (code here)
For the most part I have success, but I had very inconsistent unloads (triggering the logout) when interacting with span/option elements that load another screen. I knew of onbeforeunload's jankiness from browser to browser/version to version, but at the time it was the only idea that (mostly) worked, so my question is:
Is there a better way to solve this kind of vulnerability within the stack being used? Any conceptual suggestions or even code snippet examples would be amazing. I'm a fairly new developer and want to learn.
you can handle this with this event:
window.onunload = function(){
console.log('tab closed')
}