logout at window close event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • agarwalsunitadhn
    New Member
    • Jan 2008
    • 82

    logout at window close event

    hi....
    Currently i am working in a project where i have to maintain the time in between the user logged in. but i got a problem when the user close the application through browser window's close event.
    I am working in ASP.Net with C#
  • Shashi Sadasivan
    Recognized Expert Top Contributor
    • Aug 2007
    • 1435

    #2
    One solution would be that whenever a page is requested, it update the time of last activity. If the page is requested and the time of last activity of that user exceeds the defined time interval then you may log the user out or take appropriate actions.

    If you want to handle window closing ,i dont think even a javascript might help with that. I dont have experience with javascript, but only that could detect if the window is closed and send an appropriate response to the server, however if the window is closed, that javascript will seize to complete.

    Comment

    • agarwalsunitadhn
      New Member
      • Jan 2008
      • 82

      #3
      Originally posted by Shashi Sadasivan
      One solution would be that whenever a page is requested, it update the time of last activity. If the page is requested and the time of last activity of that user exceeds the defined time interval then you may log the user out or take appropriate actions.

      If you want to handle window closing ,i dont think even a javascript might help with that. I dont have experience with javascript, but only that could detect if the window is closed and send an appropriate response to the server, however if the window is closed, that javascript will seize to complete.
      I want to handle the close event how they performed doesnt matter. bt i have to maintain the logout time that is what time user spends by online to the site. i dont understand when to fire the code.
      Please give me some suggestion that how can i perform that.

      Thanks

      Comment

      • Plater
        Recognized Expert Expert
        • Apr 2007
        • 7872

        #4
        You could, for all your pages, have a javascript that fires on interval (once every 10-30secs?) that acts as a "heart beat", which can be used to tell if the user has left your pages or not.

        Comment

        • agarwalsunitadhn
          New Member
          • Jan 2008
          • 82

          #5
          Originally posted by Plater
          You could, for all your pages, have a javascript that fires on interval (once every 10-30secs?) that acts as a "heart beat", which can be used to tell if the user has left your pages or not.
          hello platter

          Do u want to tell that i call a javascript which runs after every 20-30 second.
          Bt if a user close browser in between this then how can i handle the logout event.
          Can u provide me a little bit of code that how can i do that?

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            Well if you're getting that "heartbeat" from the user, you know they are still on the page. If they log out or close the browser window, you won't be getting that heartbeat and can tell that they are not there anymore.
            It's not a simple thing to implement, but what you request is not a normal behavior of web applications and some work will have to be put forth to achieve this.

            Comment

            Working...