end session when the browser window is closed.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • sun

    end session when the browser window is closed.

    I want to do clean up routine to my database when the browser is closed. I
    have my code in session-end - but it never fires when the browser closes. I
    cant do onbeforeunload as it will be fired each time when the browser posts
    back.
    Somehow I want to capture browser close event and fire session abandon which
    will call session end. Please help.
    Thanks,
    Sun
  • James Steele

    #2
    Re: end session when the browser window is closed.

    Hi Sun,

    I don't beleive you can "reliably detect" a browser closing.
    Have you tried employing some type of session timeout which would fire
    the session end?

    Comment

    • Eliyahu Goldin

      #3
      Re: end session when the browser window is closed.

      Consider using HttpResponse.Is ClientConnected property.

      Eliyahu

      "sun" <sun@discussion s.microsoft.com > wrote in message
      news:5E6B52AE-BD80-4C84-8E72-E351A2AFBDB0@mi crosoft.com...[color=blue]
      > I want to do clean up routine to my database when the browser is closed.[/color]
      I[color=blue]
      > have my code in session-end - but it never fires when the browser closes.[/color]
      I[color=blue]
      > cant do onbeforeunload as it will be fired each time when the browser[/color]
      posts[color=blue]
      > back.
      > Somehow I want to capture browser close event and fire session abandon[/color]
      which[color=blue]
      > will call session end. Please help.
      > Thanks,
      > Sun[/color]


      Comment

      • sun

        #4
        Re: end session when the browser window is closed.

        How or where do I have to use HttoResponse.Is ClientConnected property
        Sun

        "Eliyahu Goldin" wrote:
        [color=blue]
        > Consider using HttpResponse.Is ClientConnected property.
        >
        > Eliyahu
        >
        > "sun" <sun@discussion s.microsoft.com > wrote in message
        > news:5E6B52AE-BD80-4C84-8E72-E351A2AFBDB0@mi crosoft.com...[color=green]
        > > I want to do clean up routine to my database when the browser is closed.[/color]
        > I[color=green]
        > > have my code in session-end - but it never fires when the browser closes.[/color]
        > I[color=green]
        > > cant do onbeforeunload as it will be fired each time when the browser[/color]
        > posts[color=green]
        > > back.
        > > Somehow I want to capture browser close event and fire session abandon[/color]
        > which[color=green]
        > > will call session end. Please help.
        > > Thanks,
        > > Sun[/color]
        >
        >
        >[/color]

        Comment

        • Eliyahu Goldin

          #5
          Re: end session when the browser window is closed.

          Start from googling newsgroups to see how other people use it. I don't have
          personal experience with it, that's why I put a careful "Consider" in my
          post. Could be it doesn't help at all. Consider it. Make your own research.

          Eliyahu

          "sun" <sun@discussion s.microsoft.com > wrote in message
          news:310C50F8-253D-493E-BF5B-4DC170586808@mi crosoft.com...[color=blue]
          > How or where do I have to use HttoResponse.Is ClientConnected property
          > Sun
          >
          > "Eliyahu Goldin" wrote:
          >[color=green]
          > > Consider using HttpResponse.Is ClientConnected property.
          > >
          > > Eliyahu
          > >
          > > "sun" <sun@discussion s.microsoft.com > wrote in message
          > > news:5E6B52AE-BD80-4C84-8E72-E351A2AFBDB0@mi crosoft.com...[color=darkred]
          > > > I want to do clean up routine to my database when the browser is[/color][/color][/color]
          closed.[color=blue][color=green]
          > > I[color=darkred]
          > > > have my code in session-end - but it never fires when the browser[/color][/color][/color]
          closes.[color=blue][color=green]
          > > I[color=darkred]
          > > > cant do onbeforeunload as it will be fired each time when the browser[/color]
          > > posts[color=darkred]
          > > > back.
          > > > Somehow I want to capture browser close event and fire session abandon[/color]
          > > which[color=darkred]
          > > > will call session end. Please help.
          > > > Thanks,
          > > > Sun[/color]
          > >
          > >
          > >[/color][/color]


          Comment

          • Josh

            #6
            Re: end session when the browser window is closed.

            > Somehow I want to capture browser close event and fire session abandon[color=blue]
            > which
            > will call session end. Please help.[/color]

            I think you are missing a trick. The behaviour is a feature. I think users
            can close thier browser and then reconnect to thier session if it was an
            accident.

            What do you have to clear out? Have you got a lot of data in the session?


            Comment

            • Patrice

              #7
              Re: end session when the browser window is closed.

              My personal preference is to not tied clean up to the normal application
              flow. I tend to prefer to have a dedicated clean up routine that cleans
              whatever needs to be cleaned.

              You could use onbeforeclose but it's likely you'll find cases where it
              doesn't fire (such as crashed browser etc...) plus session_end don't work
              for other session providers etc...

              Patrice

              --

              "sun" <sun@discussion s.microsoft.com > a écrit dans le message de
              news:5E6B52AE-BD80-4C84-8E72-E351A2AFBDB0@mi crosoft.com...[color=blue]
              > I want to do clean up routine to my database when the browser is closed.[/color]
              I[color=blue]
              > have my code in session-end - but it never fires when the browser closes.[/color]
              I[color=blue]
              > cant do onbeforeunload as it will be fired each time when the browser[/color]
              posts[color=blue]
              > back.
              > Somehow I want to capture browser close event and fire session abandon[/color]
              which[color=blue]
              > will call session end. Please help.
              > Thanks,
              > Sun[/color]


              Comment

              • Eliyahu Goldin

                #8
                Re: end session when the browser window is closed.

                > I think users[color=blue]
                > can close thier browser and then reconnect to thier session if it was an
                > accident.[/color]
                No, they can't, even if it was an accident.


                Comment

                • James Steele

                  #9
                  Re: end session when the browser window is closed.

                  More specifically.. once the parent window and ALL child windows (app
                  may have used window.open to open other windows under the same session)
                  have been closed.

                  Comment

                  Working...