Let's say the user "Bob" comes to your site, and already has one of your cookies identifying him as "Bob".
Now, to find out what Bob's been doing, you actually need to change all of your scripts to support such tracking.
However, the change is nothing more than inserting something like:
include("track.php");
You need to make sure that your script isn't terminating before track.php (we'll call the script you'll write "track.php", to see what user is doing what, when and how...or something) is included.
Now, for the most basic level you will create in track.php your code.
Include the code in <?php and ?> so PHP will parse your code, rather than just treating it as normal text.
In the code you get the cookies info, write the time, date, and page the user requested to file/database, then end the code.
Be sure not to use "exit" in your code, as it will terminate the original script that include()ed the file in the first place.
You can exand this even farther by adding various functions that allow you to save data (with their other hit data) if they did something like fail their login, what name/pass they were using when they tried it, etc etc.
If your wondering how to add what page the user requested, use $PHP_SELF in the included file.
While you may think that it would print out the location of the included file, it actually doesn't. It prints the location of the script that called the file. Good to know if you didn't already 🙂 learned that 1 minute ago
I think that about covers it...hopefully.