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. How to Maintian Who is online.

How to Maintian Who is online.

Scheduled Pinned Locked Moved ASP.NET
tutorial
10 Posts 4 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.
  • B Offline
    B Offline
    banker_kiran
    wrote on last edited by
    #1

    Hi, In my web application i want to maintain list of number of user is online. If one of them close browser without sign out then he/she will not be displayed in list. And also i want to restrict multiple login by one user in different browser. :)

    Kiran Banker

    C N N 3 Replies Last reply
    0
    • B banker_kiran

      Hi, In my web application i want to maintain list of number of user is online. If one of them close browser without sign out then he/she will not be displayed in list. And also i want to restrict multiple login by one user in different browser. :)

      Kiran Banker

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      banker_kiran wrote:

      If one of them close browser without sign out then he/she will not be displayed in list.

      You can do this with AJAX. Otherwise, you have to wait for their session to time out.

      banker_kiran wrote:

      And also i want to restrict multiple login by one user in different browser.

      Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      N B 2 Replies Last reply
      0
      • B banker_kiran

        Hi, In my web application i want to maintain list of number of user is online. If one of them close browser without sign out then he/she will not be displayed in list. And also i want to restrict multiple login by one user in different browser. :)

        Kiran Banker

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

        Many times answered for the same question by different people. Try doing a serch on this discussion board.


        My Website | Ask smart questions

        1 Reply Last reply
        0
        • B banker_kiran

          Hi, In my web application i want to maintain list of number of user is online. If one of them close browser without sign out then he/she will not be displayed in list. And also i want to restrict multiple login by one user in different browser. :)

          Kiran Banker

          N Offline
          N Offline
          NetRams
          wrote on last edited by
          #4

          To maintain online users, you should go with database. On closing browser using javascript onUnload event check the window size and if less than or equal to zero update the logout flag in database as false thru AJAX. On every time login show the online users with that flag as true.

          Be simple and Be sample.

          1 Reply Last reply
          0
          • C Christian Graus

            banker_kiran wrote:

            If one of them close browser without sign out then he/she will not be displayed in list.

            You can do this with AJAX. Otherwise, you have to wait for their session to time out.

            banker_kiran wrote:

            And also i want to restrict multiple login by one user in different browser.

            Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.

            Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

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

            Christian Graus wrote:

            Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.

            Is it a good practice on believing javascript for this ? In a worst case scenario, what will happen if user system got hanged and need a restart ? So the flag there in user table still show he is online, and prevents him from logging again. I think there is no efficient methods for this. What do you say ?


            My Website | Ask smart questions

            B C 2 Replies Last reply
            0
            • C Christian Graus

              banker_kiran wrote:

              If one of them close browser without sign out then he/she will not be displayed in list.

              You can do this with AJAX. Otherwise, you have to wait for their session to time out.

              banker_kiran wrote:

              And also i want to restrict multiple login by one user in different browser.

              Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.

              Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

              B Offline
              B Offline
              banker_kiran
              wrote on last edited by
              #6

              Hi, Thanks for Reply Can I check that current session_id is live or dead. If i get that then i can compare it with session id stored in database, if it is still live then i can restrict user from login.

              kiranbanker

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

                Christian Graus wrote:

                Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.

                Is it a good practice on believing javascript for this ? In a worst case scenario, what will happen if user system got hanged and need a restart ? So the flag there in user table still show he is online, and prevents him from logging again. I think there is no efficient methods for this. What do you say ?


                My Website | Ask smart questions

                B Offline
                B Offline
                banker_kiran
                wrote on last edited by
                #7

                If system is hanged, now he/or she has shutdown system, now he/she wants to login once again then. how do i change flag,

                kiranbanker

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

                  Christian Graus wrote:

                  Easy, have an 'is logged in' property on the user table, if they are logged in, either log out the old session ( better ), or refuse login.

                  Is it a good practice on believing javascript for this ? In a worst case scenario, what will happen if user system got hanged and need a restart ? So the flag there in user table still show he is online, and prevents him from logging again. I think there is no efficient methods for this. What do you say ?


                  My Website | Ask smart questions

                  C Offline
                  C Offline
                  Christian Graus
                  wrote on last edited by
                  #8

                  N a v a n e e t h wrote:

                  Is it a good practice on believing javascript for this ?

                  Well, AJAX is the only way you can find out if the browser was closed. It's wise to add code to manually clear sessions you know have timed out, also, if you must do this at all.

                  N a v a n e e t h wrote:

                  So the flag there in user table still show he is online, and prevents him from logging again.

                  That's the main reason that I said it's better to kill the old session and allow a new login to take precedence.

                  N a v a n e e t h wrote:

                  I think there is no efficient methods for this. What do you say ?

                  Yes, it's messy, no matter how you look at it.

                  Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                  N 1 Reply Last reply
                  0
                  • C Christian Graus

                    N a v a n e e t h wrote:

                    Is it a good practice on believing javascript for this ?

                    Well, AJAX is the only way you can find out if the browser was closed. It's wise to add code to manually clear sessions you know have timed out, also, if you must do this at all.

                    N a v a n e e t h wrote:

                    So the flag there in user table still show he is online, and prevents him from logging again.

                    That's the main reason that I said it's better to kill the old session and allow a new login to take precedence.

                    N a v a n e e t h wrote:

                    I think there is no efficient methods for this. What do you say ?

                    Yes, it's messy, no matter how you look at it.

                    Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

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

                    Christian Graus wrote:

                    Yes, it's messy, no matter how you look at it.

                    Yes it is. It's not possible to believe on session_end also, which won't be fired all time, and it's specific for InProc. I have seen some examples which explains this in much more efficient way by making use of cache. Cache timeout will be set as session timeout time and assign a callback function when cache timed out. Inside this function we will be able to update the flag. This looks much closer to the problem. ?


                    My Website | Ask smart questions

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

                      Christian Graus wrote:

                      Yes, it's messy, no matter how you look at it.

                      Yes it is. It's not possible to believe on session_end also, which won't be fired all time, and it's specific for InProc. I have seen some examples which explains this in much more efficient way by making use of cache. Cache timeout will be set as session timeout time and assign a callback function when cache timed out. Inside this function we will be able to update the flag. This looks much closer to the problem. ?


                      My Website | Ask smart questions

                      C Offline
                      C Offline
                      Christian Graus
                      wrote on last edited by
                      #10

                      With AJAX, you can capture a client side event when the browser is closed, and send a message to the server. That's what I was referring to. But, it's still messy. Turn the power off, that's the obvious example that you cannot code for.

                      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

                      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