Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Check Browser Close Event

Check Browser Close Event

Scheduled Pinned Locked Moved ASP.NET
csharpjavascriptasp-nethelptutorial
10 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Abubakarsb
    wrote on last edited by
    #1

    Good Morning, Is it possible to fire an event when user closes the browser window in javascript or any other language? Please help. I have user a login system in my project which is being made in asp.net 2.0. I want that when user closes the browser window it should logout autmatically. If anyone of you knows about it please guide me. Thanks. waiting for reply. Bye. Abubakar

    S N 2 Replies Last reply
    0
    • A Abubakarsb

      Good Morning, Is it possible to fire an event when user closes the browser window in javascript or any other language? Please help. I have user a login system in my project which is being made in asp.net 2.0. I want that when user closes the browser window it should logout autmatically. If anyone of you knows about it please guide me. Thanks. waiting for reply. Bye. Abubakar

      S Offline
      S Offline
      SHatchard
      wrote on last edited by
      #2

      I saw an good article the other day on handing browser close events on the server side http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide[^] Hope it helps

      A S 2 Replies Last reply
      0
      • S SHatchard

        I saw an good article the other day on handing browser close events on the server side http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide[^] Hope it helps

        A Offline
        A Offline
        Abubakarsb
        wrote on last edited by
        #3

        Thanks for reply. I don't think it could be solution becaue "onunload" function will be called every time even user moves to another page by clicking a link then user will be logout which is not right. what do u think?

        1 Reply Last reply
        0
        • S SHatchard

          I saw an good article the other day on handing browser close events on the server side http://aspalliance.com/1294_CodeSnip_Handle_Browser_Close_Event_on_the_ServerSide[^] Hope it helps

          S Offline
          S Offline
          Sonia Gupta
          wrote on last edited by
          #4

          hi there ca u provide the link other then ajax thanQ

          Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....

          1 Reply Last reply
          0
          • A Abubakarsb

            Good Morning, Is it possible to fire an event when user closes the browser window in javascript or any other language? Please help. I have user a login system in my project which is being made in asp.net 2.0. I want that when user closes the browser window it should logout autmatically. If anyone of you knows about it please guide me. Thanks. waiting for reply. Bye. Abubakar

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            Abubakarsb wrote:

            I want that when user closes the browser window it should logout autmatically.

            Session will have some timeout specified. It will end after that time. So no need to end it explicitly when user closes browser. And I don't think that doing this using javascript will be a good solution, because if javascript is disabled on user browser, your script won't work. Are you updating any value in database when user logs out ?


            My Website | Ask smart questions

            V A 2 Replies Last reply
            0
            • N N a v a n e e t h

              Abubakarsb wrote:

              I want that when user closes the browser window it should logout autmatically.

              Session will have some timeout specified. It will end after that time. So no need to end it explicitly when user closes browser. And I don't think that doing this using javascript will be a good solution, because if javascript is disabled on user browser, your script won't work. Are you updating any value in database when user logs out ?


              My Website | Ask smart questions

              V Offline
              V Offline
              Vasudevan Deepak Kumar
              wrote on last edited by
              #6

              N a v a n e e t h wrote:

              Are you updating any value in database when user logs out ?

              Check out this article if you are depending on Session_OnEnd for your logic: http://www.eggheadcafe.com/articles/20030418.asp[^]

              Vasudevan Deepak Kumar Personal Homepage Tech Gossips

              N 1 Reply Last reply
              0
              • V Vasudevan Deepak Kumar

                N a v a n e e t h wrote:

                Are you updating any value in database when user logs out ?

                Check out this article if you are depending on Session_OnEnd for your logic: http://www.eggheadcafe.com/articles/20030418.asp[^]

                Vasudevan Deepak Kumar Personal Homepage Tech Gossips

                N Offline
                N Offline
                N a v a n e e t h
                wrote on last edited by
                #7

                Vasudevan Deepak Kumar wrote:

                Check out this article if you are depending on Session_OnEnd for your logic:

                Yes read that more than 3 times, all from your message only. But I didn't had any problem with firing session_end event. It works perfectly for me. I feel in article they are concentrating on webfarms, and this thread starter has not told that he is using a webfarm. He may be using InProc, and for that session_end will easy and optimum ? What do you say ?


                My Website | Ask smart questions

                1 Reply Last reply
                0
                • N N a v a n e e t h

                  Abubakarsb wrote:

                  I want that when user closes the browser window it should logout autmatically.

                  Session will have some timeout specified. It will end after that time. So no need to end it explicitly when user closes browser. And I don't think that doing this using javascript will be a good solution, because if javascript is disabled on user browser, your script won't work. Are you updating any value in database when user logs out ?


                  My Website | Ask smart questions

                  A Offline
                  A Offline
                  Abubakarsb
                  wrote on last edited by
                  #8

                  No, I am not updating any value. I am just logging out of user from the system. The problem is sometimes when I close the browser it loged out user but when I try to relogin again with same username it says "User is currently Login"

                  N 1 Reply Last reply
                  0
                  • A Abubakarsb

                    No, I am not updating any value. I am just logging out of user from the system. The problem is sometimes when I close the browser it loged out user but when I try to relogin again with same username it says "User is currently Login"

                    N Offline
                    N Offline
                    N a v a n e e t h
                    wrote on last edited by
                    #9

                    Abubakarsb wrote:

                    it says "User is currently Login"

                    How you are checking this ? That's what I asked are you storing any values to identify whether user is online ?


                    My Website | Ask smart questions

                    A 1 Reply Last reply
                    0
                    • N N a v a n e e t h

                      Abubakarsb wrote:

                      it says "User is currently Login"

                      How you are checking this ? That's what I asked are you storing any values to identify whether user is online ?


                      My Website | Ask smart questions

                      A Offline
                      A Offline
                      Abubakarsb
                      wrote on last edited by
                      #10

                      Sorry guys! I was really busy with other parts of my project. Regarding to your question "How you are checking this ? That's what I asked are you storing any values to identify whether user is online ? " The thing is I am new in Visual Studio 2005 (Asp.net 2.0) and a developer already made this, I am just updating it. I don't have any idea how new login system works in VS2005. I really don't know how he is storing or checking that whether user is login or not? He made a commonMaster page and I have found a check please check code below, may be it helps you to understand my problem, if you still need more please don't hasitate. I want to fix this soon. Thanks. if (Properties.IsLoggedIn) { string cookieName = FormsAuthentication.FormsCookieName; HttpCookie authCookie = Context.Request.Cookies[cookieName]; FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); MembershipUser mu = Membership.GetUser(); Properties.EndUserGUID = mu.ProviderUserKey.ToString().ToUpper(); DateTime expiration = authTicket.Expiration.AddSeconds(-90); if (expiration < DateTime.Now) { mu.LastLoginDate = DateTime.Now; Membership.UpdateUser(mu); FormsAuthentication.SetAuthCookie(Context.User.Identity.Name, true, "/"); } }

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups