find the number of users viewing a website at any point of time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rahullko05
    New Member
    • Oct 2008
    • 34

    find the number of users viewing a website at any point of time

    Hi,
    I am writing a code to display the number of user currently viewing my website at any point of time.
    for example: for bytes i can see
    network: 216355 as number of users currently viewing this website currently.

    Also i want to know how can i get the IP address of machine from where the site is viewed or atleast user has logged in to my website. i want to keep track of this information.
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    There is no perfect way to tell how many people are viewing your site at any given time. I'm sure people will disagree, but w/e.

    The best way to do this, is to log into your database the time of visit and the ip (available from $_SERVER['REMOTE_ADDR']). Then, when you want to display the current amount of visitors, query the database for the visits that are only a minute or 2 old. That way, it gives you a better answer.

    Comment

    • rahullko05
      New Member
      • Oct 2008
      • 34

      #3
      thanks, this solves my problem

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by rahullko05
        thanks, this solves my problem
        Glad I could help,

        Markus.

        Comment

        • abhighat4214
          New Member
          • Jul 2008
          • 13

          #5
          Yeah I agree , may be you can log the log in and log out time in database , execute the SQL count (*) function to keep track of number of users , but Yeah , I agree with the previous post, there is no perfect way to know how many people are using your site at a givne time.
          Regards,
          Abhijit

          Comment

          Working...