I'm trying to end a user's session when they close the browser,
because they never logout properly.

I need to change a value in the db after they close the browser only.

<script type="text/javascript">
    window.onbeforeunload = check;
    function check() {
        return "Are you sure you want to exit this page?";
        //or put whatever function you need to call when a user closes the web //browser.


This does work on closing the browser but unfornately also when I redirect to any other page.

Is there any way to do this for browser close only?


SessionEnd event in Global.asax? i'm not sure if that will be called when leaving the site or only after a session timeout.