Creating a “Who’s Online” script with PHP
In this tutorial I will show you how to create your own “Who’s Online” script, which is often found on message boards and other community scripts. We will first create a really simple script, and after that add a few more features like the location of each visitor. But first, let me explain how our “Who’s Online” script is going to work.
Our script will store a visitor’s IP address and last active timestamp in a database, and update it every time the visitor requests one of our pages. The script will actually be a web bug, and run completely in the background.