Hi

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.
        endSession();

    }
</script>

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?

Grant.

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.