Count visitors on my website

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

    #1

    Count visitors on my website

    Hi I've seen this a few places - The site lists off the number of
    people (not logged in) currently browsing the site. How can I do this
    with php / mySQL please?

  • Michael Fesser

    #2
    Re: Count visitors on my website

    ..oO(Ciaran)
    >Hi I've seen this a few places - The site lists off the number of
    >people (not logged in) currently browsing the site. How can I do this
    >with php / mySQL please?
    You can use rand().

    Such "statistics " are never accurate. HTTP is a stateless protocol,
    there's no such thing like a "currently online user". A user comes,
    sends a request, gets a response and is gone. Next request, next user.

    Micha

    Comment

    • axlq

      #3
      Re: Count visitors on my website

      In article <6usf9316qblqv2 o9d4ae6547jr20i itqbk@4ax.com>,
      Michael Fesser <netizen@gmx.de wrote:
      >.oO(Ciaran)
      >>Hi I've seen this a few places - The site lists off the number of
      >>people (not logged in) currently browsing the site. How can I do this
      >>with php / mySQL please?
      >
      >You can use rand().
      >
      >Such "statistics " are never accurate. HTTP is a stateless protocol,
      >there's no such thing like a "currently online user". A user comes,
      >sends a request, gets a response and is gone. Next request, next user.
      The VBulletin software not only says how many users are logged in and
      using the forum, but also lists their names.

      It is reasonable to assume that for a site like a forum, if a user
      logs in, that user will probably still be looking at the forum a
      minute after the user's most recent activity. It should be easy to
      keep a running database of users whose recent activity is less than,
      say, 5 minutes ago. The list could be displayed alphabetically or
      sorted by timestamp.

      -A

      Comment

      • Jerry Stuckle

        #4
        Re: Count visitors on my website

        axlq wrote:
        In article <6usf9316qblqv2 o9d4ae6547jr20i itqbk@4ax.com>,
        Michael Fesser <netizen@gmx.de wrote:
        >.oO(Ciaran)
        >>Hi I've seen this a few places - The site lists off the number of
        >>people (not logged in) currently browsing the site. How can I do this
        >>with php / mySQL please?
        >You can use rand().
        >>
        >Such "statistics " are never accurate. HTTP is a stateless protocol,
        >there's no such thing like a "currently online user". A user comes,
        >sends a request, gets a response and is gone. Next request, next user.
        >
        The VBulletin software not only says how many users are logged in and
        using the forum, but also lists their names.
        >
        It is reasonable to assume that for a site like a forum, if a user
        logs in, that user will probably still be looking at the forum a
        minute after the user's most recent activity. It should be easy to
        keep a running database of users whose recent activity is less than,
        say, 5 minutes ago. The list could be displayed alphabetically or
        sorted by timestamp.
        >
        -A
        No, that is not a reasonable assumption. Some people may stay 10
        second, others 10 hours.

        As Micha said - HTTP is a stateless protocol. All you really know is
        that the user is *probably* still there when a response is being sent.
        But even that is not for sure.

        Any other figure is a pure crap shoot.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        • Hadron

          #5
          Re: Count visitors on my website

          Michael Fesser <netizen@gmx.de writes:
          .oO(Ciaran)
          >
          >>Hi I've seen this a few places - The site lists off the number of
          >>people (not logged in) currently browsing the site. How can I do this
          >>with php / mySQL please?
          >
          You can use rand().
          >
          Such "statistics " are never accurate. HTTP is a stateless protocol,
          there's no such thing like a "currently online user". A user comes,
          sends a request, gets a response and is gone. Next request, next user.
          >
          Micha
          So you clearly have no clue.

          PHP maintains sessions and the user can be logged for that duration and
          therefore only counted once.

          Comment

          • rf

            #6
            Re: Count visitors on my website


            "Hadron" <hadronquark@gm ail.comwrote in message
            news:87wsx234al .fsf@gmail.com. ..
            Michael Fesser <netizen@gmx.de writes:
            >
            >.oO(Ciaran)
            >>
            >>>Hi I've seen this a few places - The site lists off the number of
            >>>people (not logged in) currently browsing the site. How can I do this
            >>>with php / mySQL please?
            >>
            >You can use rand().
            >>
            >Such "statistics " are never accurate. HTTP is a stateless protocol,
            >there's no such thing like a "currently online user". A user comes,
            >sends a request, gets a response and is gone. Next request, next user.
            >>
            >Micha
            >
            So you clearly have no clue.
            Ha!
            PHP maintains sessions and the user can be logged for that duration and
            therefore only counted once.
            And it clearly says right up there in the Original Post: "not logged in".

            That means no session.

            And even if there *is* a session how do you know the user hasn't opened a
            new tab and is busily looking at somebody elses site, or turned their
            computer off, or simply wandered off down to the pub for lunch?

            With sessions you can tell how many people have used your login form and
            have yet to use your logout form, or yet to be timed out. You can not tell
            how many people are "browsing the site".

            I administer several sites that use logins. Sometimes I visit one only to
            find that I had last "logged in" several days ago and my browser is still
            hanging on to the session cookie.

            --
            Richard.


            Comment

            • Michael Fesser

              #7
              Re: Count visitors on my website

              ..oO(Hadron)
              >Michael Fesser <netizen@gmx.de writes:
              >
              >Such "statistics " are never accurate. HTTP is a stateless protocol,
              >there's no such thing like a "currently online user". A user comes,
              >sends a request, gets a response and is gone. Next request, next user.
              >
              >So you clearly have no clue.
              Sure?
              >PHP maintains sessions and the user can be logged for that duration and
              >therefore only counted once.
              You are the second one in this thread who obviously didn't read the "not
              logged in" in the original post.

              And what does session counting tell you? Sessions can be open for hours
              without any user interaction. The user could have died already in front
              of his monitor and his session would still be open.

              Whatever way you go - it's always just guessing. So why bother at all?
              Why show a questionable "informatio n" that is of absolutely no use for
              the visitor? Just to show how cool and active the "community" is? If you
              want that you can use rand() - it's much easier than all others methods.

              Micha

              Comment

              • Gordon Burditt

                #8
                Re: Count visitors on my website

                >>>>Hi I've seen this a few places - The site lists off the number of
                >>>>people (not logged in) currently browsing the site. How can I do this
                >>>>with php / mySQL please?
                >>>
                >>You can use rand().
                >>>
                >>Such "statistics " are never accurate. HTTP is a stateless protocol,
                >>there's no such thing like a "currently online user". A user comes,
                >>sends a request, gets a response and is gone. Next request, next user.
                >>>
                >>Micha
                >>
                >So you clearly have no clue.
                >
                >Ha!
                >
                >PHP maintains sessions and the user can be logged for that duration and
                >therefore only counted once.
                >
                >And it clearly says right up there in the Original Post: "not logged in".
                >
                >That means no session.
                No, "not logged in" does *NOT* mean "no session". For some login
                setups, "no session" (e.g. they've got cookies turned off, and
                you're not passing the session identifier in the URL) means "no
                ability to sustain a login", but that's a completely different
                issue.
                >And even if there *is* a session how do you know the user hasn't opened a
                >new tab and is busily looking at somebody elses site, or turned their
                >computer off, or simply wandered off down to the pub for lunch?
                Or is talking on the phone, or is asleep, or ...
                >With sessions you can tell how many people have used your login form and
                >have yet to use your logout form, or yet to be timed out. You can not tell
                >how many people are "browsing the site".
                Sessions do not require a login form. But even if you have a "logout form",
                users hardly ever use it unless there's some really sensitive information
                or control with it (like online banking). About the only thing you can
                do is assume a timeout: no hit in N minutes for that session, they've
                probably left.
                >I administer several sites that use logins. Sometimes I visit one only to
                >find that I had last "logged in" several days ago and my browser is still
                >hanging on to the session cookie.
                If you're trying to count "unique visitors", you've got an even worse
                problem. Spammers often sign up multiple accounts for the same user.

                Comment

                • Hadron

                  #9
                  Re: Count visitors on my website

                  Michael Fesser <netizen@gmx.de writes:
                  .oO(Hadron)
                  >
                  >>Michael Fesser <netizen@gmx.de writes:
                  >>
                  >>Such "statistics " are never accurate. HTTP is a stateless protocol,
                  >>there's no such thing like a "currently online user". A user comes,
                  >>sends a request, gets a response and is gone. Next request, next user.
                  >>
                  >>So you clearly have no clue.
                  >
                  Sure?
                  >
                  >>PHP maintains sessions and the user can be logged for that duration and
                  >>therefore only counted once.
                  >
                  You are the second one in this thread who obviously didn't read the "not
                  logged in" in the original post
                  I am reading the "stateless protocol" stuff above and replying to that
                  in the context of PHP.
                  ..
                  >
                  And what does session counting tell you? Sessions can be open for hours
                  without any user interaction. The user could have died already in front
                  of his monitor and his session would still be open.
                  That's not the issue. Clearly something on a server cant know IF he is
                  reading the page or not. You can only go on the connections.

                  "Currently online" has a meaning - and that is that HIS PC is
                  connected. The rest is guesswork.
                  >
                  Whatever way you go - it's always just guessing. So why bother at all?
                  Absolute tosh.
                  Why show a questionable "informatio n" that is of absolutely no use for
                  the visitor? Just to show how cool and active the "community" is? If you
                  want that you can use rand() - it's much easier than all others
                  methods.
                  As I said - you are clueless.
                  >
                  Micha
                  --

                  Comment

                  • Hadron

                    #10
                    Re: Count visitors on my website

                    "rf" <rf@invalid.com writes:
                    "Hadron" <hadronquark@gm ail.comwrote in message
                    news:87wsx234al .fsf@gmail.com. ..
                    >Michael Fesser <netizen@gmx.de writes:
                    >>
                    >>.oO(Ciaran)
                    >>>
                    >>>>Hi I've seen this a few places - The site lists off the number of
                    >>>>people (not logged in) currently browsing the site. How can I do this
                    >>>>with php / mySQL please?
                    >>>
                    >>You can use rand().
                    >>>
                    >>Such "statistics " are never accurate. HTTP is a stateless protocol,
                    >>there's no such thing like a "currently online user". A user comes,
                    >>sends a request, gets a response and is gone. Next request, next user.
                    >>>
                    >>Micha
                    >>
                    >So you clearly have no clue.
                    >
                    Ha!
                    >
                    >PHP maintains sessions and the user can be logged for that duration and
                    >therefore only counted once.
                    >
                    And it clearly says right up there in the Original Post: "not logged
                    in".
                    So? Who is talking about "logged in"? I am talking about PHP sessions.
                    >
                    That means no session.
                    Rubbish.
                    >
                    And even if there *is* a session how do you know the user hasn't opened a
                    new tab and is busily looking at somebody elses site, or turned their
                    computer off, or simply wandered off down to the pub for lunch?
                    So what if they are? They are still connected and have a session. Of
                    course we can not know if that user is actually LOOKING - but they *ARE*
                    connected.
                    >
                    With sessions you can tell how many people have used your login form and
                    have yet to use your logout form, or yet to be timed out. You can not tell
                    how many people are "browsing the site".
                    Yes you can. Because even if they are not physically looking, they ARE
                    still browsing. Sure, we dont know if the use is asleep or on the toilet
                    but he IS still maintaining a session.
                    >
                    I administer several sites that use logins. Sometimes I visit one only to
                    find that I had last "logged in" several days ago and my browser is still
                    hanging on to the session cookie.
                    If you administer sites then I am surprised you are so clueless in the
                    context of a PHP site.

                    Comment

                    • Jerry Stuckle

                      #11
                      Re: Count visitors on my website

                      Hadron wrote:
                      >
                      >With sessions you can tell how many people have used your login form and
                      >have yet to use your logout form, or yet to be timed out. You can not tell
                      >how many people are "browsing the site".
                      >
                      Yes you can. Because even if they are not physically looking, they ARE
                      still browsing. Sure, we dont know if the use is asleep or on the toilet
                      but he IS still maintaining a session.
                      >
                      No, you can't. All you know is at some time he started a session. You
                      don't know if they are still browsing your site (or some other site),
                      have closed their browser or even turned off their computer. You get NO
                      notification when someone closes their browser or moves on to another site.
                      >I administer several sites that use logins. Sometimes I visit one only to
                      >find that I had last "logged in" several days ago and my browser is still
                      >hanging on to the session cookie.
                      >
                      If you administer sites then I am surprised you are so clueless in the
                      context of a PHP site.
                      And I'm surprised you're so clueless as to how sessions and HTTP
                      protocol in general work.

                      He's right - browsers will hang onto session cookies forever, if you
                      tell them to. And sites will keep sessions open until your PHP code
                      destroys the session or it times out - which depends on the php.ini
                      settings.


                      --
                      =============== ===
                      Remove the "x" from my email address
                      Jerry Stuckle
                      JDS Computer Training Corp.
                      jstucklex@attgl obal.net
                      =============== ===

                      Comment

                      • Jerry Stuckle

                        #12
                        Re: Count visitors on my website

                        Hadron wrote:
                        Michael Fesser <netizen@gmx.de writes:
                        >
                        >You are the second one in this thread who obviously didn't read the "not
                        >logged in" in the original post
                        >
                        I am reading the "stateless protocol" stuff above and replying to that
                        in the context of PHP.
                        >
                        Then you're not understanding what "stateless protocol" means.

                        Comment

                        • rf

                          #13
                          Re: Count visitors on my website

                          "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
                          news:4Lmdnax6xK kAvwfbnZ2dnUVZ_ t-gnZ2d@comcast.c om...
                          Hadron wrote:
                          >>Why show a questionable "informatio n" that is of absolutely no use for
                          >>the visitor? Just to show how cool and active the "community" is? If you
                          >>want that you can use rand() - it's much easier than all others
                          >>methods.
                          >>
                          >As I said - you are clueless.
                          >>
                          >
                          Yep, you are totally clueless. You have absolutely no idea how this
                          works, and think you can pull the wool over experienced programmers' eyes.
                          >
                          You can do it to clueless clients. But you can't do it here.
                          >
                          And I pity those clients.
                          You will never convice these sort of people. They, without a clear
                          understanding of how the protocol actually works, will continually insist
                          that you can tally "current viewers". I've seen it time and time again. I've
                          even explained to some of them that they will completely miss the viewer
                          that has obtained a copy of their page from a corporate proxy (with of
                          course no access at all to their server), to no avail. They simply will not
                          understand. It's right up there with "N people have visited this site
                          since..." :-)

                          Just let them put their meaningless counters on their web sites. It does no
                          harm, providing, as you say, they are not telling their "clients" that it
                          has meaning.

                          --
                          Richard


                          Comment

                          • Hadron

                            #14
                            Re: Count visitors on my website

                            Jerry Stuckle <jstucklex@attg lobal.netwrites :
                            Hadron wrote:
                            >Michael Fesser <netizen@gmx.de writes:
                            >>
                            >>You are the second one in this thread who obviously didn't read the "not
                            >>logged in" in the original post
                            >>
                            >I am reading the "stateless protocol" stuff above and replying to that
                            >in the context of PHP.
                            >>
                            >
                            Then you're not understanding what "stateless protocol" means.
                            >
                            .
                            >>And what does session counting tell you? Sessions can be open for hours
                            >>without any user interaction. The user could have died already in front
                            >>of his monitor and his session would still be open.
                            >>
                            >That's not the issue. Clearly something on a server cant know IF he is
                            >reading the page or not. You can only go on the connections.
                            >>
                            >
                            This is correct.
                            Good. Because that is ALL this is about.
                            >
                            >"Currently online" has a meaning - and that is that HIS PC is
                            >connected. The rest is guesswork.
                            >>
                            >
                            There is no way to know if someone si "currently online". All you
                            know is he was online when he last requested a page. Anything else is
                            a guess.
                            Jesus H Christ.

                            Yes. But he IS connected. The session IS open. Whether he is physically
                            sat there is something we can NEVER know.
                            >
                            >>Whatever way you go - it's always just guessing. So why bother at all?
                            >>
                            >Absolute tosh.
                            >>
                            >
                            Yep, your concept is absolute tosh.
                            Balderdash.
                            >
                            >>Why show a questionable "informatio n" that is of absolutely no use for
                            >>the visitor? Just to show how cool and active the "community" is? If you
                            >>want that you can use rand() - it's much easier than all others
                            >>methods.
                            >>
                            >As I said - you are clueless.
                            >>
                            >
                            Yep, you are totally clueless. You have absolutely no idea how this
                            works, and think you can pull the wool over experienced programmers'
                            eyes.
                            What ARE you talking about? I have implemented session based web sites.
                            >
                            You can do it to clueless clients. But you can't do it here.
                            >
                            And I pity those clients.
                            Ye gods. Go get a clue.
                            >
                            >>Micha
                            >>
                            --

                            Comment

                            • Hadron

                              #15
                              Re: Count visitors on my website

                              "rf" <rf@invalid.com writes:
                              "Jerry Stuckle" <jstucklex@attg lobal.netwrote in message
                              news:4Lmdnax6xK kAvwfbnZ2dnUVZ_ t-gnZ2d@comcast.c om...
                              >Hadron wrote:
                              >
                              >>>Why show a questionable "informatio n" that is of absolutely no use for
                              >>>the visitor? Just to show how cool and active the "community" is? If you
                              >>>want that you can use rand() - it's much easier than all others
                              >>>methods.
                              >>>
                              >>As I said - you are clueless.
                              >>>
                              >>
                              >Yep, you are totally clueless. You have absolutely no idea how this
                              >works, and think you can pull the wool over experienced programmers' eyes.
                              >>
                              >You can do it to clueless clients. But you can't do it here.
                              >>
                              >And I pity those clients.
                              >
                              You will never convice these sort of people. They, without a clear
                              understanding of how the protocol actually works, will continually insist
                              that you can tally "current viewers". I've seen it time and time
                              again. I've
                              The viewer is the session for crying out loud.
                              even explained to some of them that they will completely miss the viewer
                              that has obtained a copy of their page from a corporate proxy (with of
                              course no access at all to their server), to no avail. They simply will not
                              understand. It's right up there with "N people have visited this site
                              since..." :-)
                              >
                              Just let them put their meaningless counters on their web sites. It does no
                              harm, providing, as you say, they are not telling their "clients" that it
                              has meaning.
                              I am frightened that you seem unable to understand such simple concepts.

                              You know, I think you should suggest to banks that they dont really know
                              if someone is there and should end all session based online banking.

                              Or they could do the SENSIBLE thing and ASSUME in many cases that the
                              fact that someone opened the session means that there is a HIGH
                              PROBABILITY that someone os THERE. Possibly implement a time out. Oh,
                              they do jus that.

                              Idiot.

                              Comment

                              Working...