number of logins

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

    number of logins

    Anyone know a way to have a site list the usernames of those logged in?
    It could be done by writing to a db when a session is started and
    ended but it would be nicer if there is some global session that I can
    go through an array of users. Is that possible or is it against the
    whole spirit of sessions?

    mm?

    Hughie

  • BKDotCom

    #2
    Re: number of logins


    hughie wrote:
    Anyone know a way to have a site list the usernames of those logged in?
    It could be done by writing to a db when a session is started and
    ended but it would be nicer if there is some global session that I can
    go through an array of users. Is that possible or is it against the
    whole spirit of sessions?
    poll the db for active users.
    perhaps your DB could have a meta-data table/row
    update an "active_num_use rs" each time someone logs in/out
    either a straight-forward increment/decrement or actually test for
    "active/non-idle" users.
    of course to track that, you'd need to also store not-only when someone
    logs in, but their last activity (ie, each time they load a page)

    Comment

    • hughie

      #3
      Re: number of logins

      poll the db for active users.

      aha, you have any code for that?
      perhaps your DB could have a meta-data table/row
      update an "active_num_use rs" each time someone logs in/out
      either a straight-forward increment/decrement or actually test for
      "active/non-idle" users.
      of course to track that, you'd need to also store not-only when someone
      logs in, but their last activity (ie, each time they load a page)
      exactly..but I was hoping to find a way to do that from some uber
      session or something.
      It's starting to look like going the db table way is probably best.

      Hughie

      Comment

      • Tim Van Wassenhove

        #4
        Re: number of logins

        hughie schreef:
        Anyone know a way to have a site list the usernames of those logged in?
        How would you define a user that is logged in? (Please take into
        consideration that http is stateless when you come up with a definition)
        it would be nicer if there is some global session that I can
        go through an array of users.
        And how would that global session be shared over all servers that host
        your webapplication?


        --
        Tim Van Wassenhove <url:http://www.timvw.be/>

        Comment

        • hughie

          #5
          Re: number of logins


          Tim Van Wassenhove wrote:
          How would you define a user that is logged in? (Please take into
          consideration that http is stateless when you come up with a definition)
          When a user enters a correct username and password then a session is
          created for them. During the lifetime of that session I'm calling that
          'logged in'.
          And how would that global session be shared over all servers that host
          your webapplication?
          The app is only on one server. I realise that if it were distributed
          then using the db for this is best. Can I assume your question is
          partly rhetorical? I'm just trying to find out a good way to do it.

          Comment

          • Tim Van Wassenhove

            #6
            Re: number of logins

            hughie schreef:
            Tim Van Wassenhove wrote:
            >How would you define a user that is logged in? (Please take into
            >consideratio n that http is stateless when you come up with a definition)
            >
            When a user enters a correct username and password then a session is
            created for them. During the lifetime of that session I'm calling that
            'logged in'.
            And where is the session data stored? Since that is the place where you
            will find all the information about (current) sessions... (Eg: iterate
            over the files in session.save_pa th)


            --
            Tim Van Wassenhove <url:http://www.timvw.be/>

            Comment

            • Gordon Burditt

              #7
              Re: number of logins

              >How would you define a user that is logged in? (Please take into
              >consideratio n that http is stateless when you come up with a definition)
              >
              >When a user enters a correct username and password then a session is
              >created for them. During the lifetime of that session I'm calling that
              >'logged in'.
              Now, when is a session DELETED? Hint: users don't use logout
              buttons, except maybe by accident. They click on an ad and never
              come back, their browser crashes, they just leave for a 3-week
              vacation, etc.
              >And how would that global session be shared over all servers that host
              >your webapplication?
              >
              >The app is only on one server. I realise that if it were distributed
              >then using the db for this is best. Can I assume your question is
              >partly rhetorical? I'm just trying to find out a good way to do it.
              You can use a session save handler which puts the session data in
              a database. That way it's shared across all servers.


              Comment

              • Rik

                #8
                Re: number of logins

                hughie wrote:
                >poll the db for active users.
                >
                aha, you have any code for that?
                Google jpmaster77 login script.
                >perhaps your DB could have a meta-data table/row
                >update an "active_num_use rs" each time someone logs in/out
                >either a straight-forward increment/decrement or actually test for
                >"active/non-idle" users.
                >of course to track that, you'd need to also store not-only when
                >someone logs in, but their last activity (ie, each time they load a
                >page)
                >
                exactly..but I was hoping to find a way to do that from some uber
                session or something.
                It's starting to look like going the db table way is probably best.
                Probably the fastest & most reliable solution indeed.

                --
                Rik Wasmus


                Comment

                • hughie

                  #9
                  Re: number of logins

                  thanks all - i've built it thusly: my login script writes a unix
                  datetime stamp to the db, my pages check it and fiddles with the times
                  and things. I appreciate the advice.

                  Hughie

                  Comment

                  • hughie

                    #10
                    Re: number of logins


                    usenet@isotopeR EEMOOVEmedia.co m wrote:
                    On 28 Dec 2006 06:03:40 -0800, "hughie" <hughie.carroll @gmail.comwrote :
                    >
                    thanks all - i've built it thusly: my login script writes a unix
                    datetime stamp to the db, my pages check it and fiddles with the times
                    and things. I appreciate the advice.
                    >
                    I'm catching this thread late, but you might want to check out DB_eSession.

                    >
                    It doesn't look like it's updated anymore, but . . .
                    thanks for that - i've got deep into my own coding and it's going ok so
                    i'll stay with that for the time being.

                    H

                    Comment

                    Working...