Forum Moderators: coopster

Message Too Old, No Replies

Users Online stats with PHP?

I want to have a page that will display how many

         

kindred1

9:02 pm on Jan 1, 2003 (gmt 0)

10+ Year Member



I want to have a page that will display how many users are on my website at any given time.I heard there was a simple PHP script to do that,but i cant find it.

All i want it to do is display how may people are viewing my website.Thanks for any help...

frappyjohn

7:36 am on Jan 2, 2003 (gmt 0)

10+ Year Member



One basic problem with the task is you have no way of knowing when someone leaves your site!

You can try to keep track by using the javascript onclose function to route your visitors through an exit page, but that will get pretty complicated pretty fast.

You'd probably do best to settle for a tally of the number of visitors who have been served a page in the last 5 or 10 minutes.

I'm a novice at PHP so I will leave the details to others, but I would think one approach would be to write each visitor's IP address to a file along with the current timestamp. Then you could have a routine that reads the file, filters out any that are over the limit of 5 or 10 minutes, and writes it out again, tallying the unique IP addresses in the process.

dingman

1:00 pm on Jan 2, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you're going to process a text file, why write it yourself? You've got IP addresses and timestamps in your server logs already :)

If you do keep your own log, make sure that you include some mechanism for clearing out stale entries. Otherwise your log file will grow forever, and eventually you'll be taking a noticable ammount of time just to parse it at each page load.

BjarneDM

1:01 am on Jan 6, 2003 (gmt 0)

10+ Year Member



take a look here: [webmasterworld.com...]
it should be possible to do this from inside php