^ agree with eelixduppy
You could do something~ like you want with simple code like:
<?php
session_start();
if ($_SESSION['tracking']['set']===true)
{
//Update Tracking
$_SESSION['tracking']['last'] = $_SESSION['tracking']['current'];
$_SESSION['tracking']['lastREQ'] = $_SESSION['tracking']['REQ'];
$_SESSION['tracking']['current'] = time();
$_SESSION['tracking']['REQ'] = $_SERVER['REQUEST_URI'];
}
else
{
//Setup New Tracking
$_SESSION['tracking']['set'] = true;
$_SESSION['tracking']['current'] = time();
$_SESSION['tracking']['REQ'] = $_SERVER['REQUEST_URI'];
$_SESSION['tracking']['last'] = 0;
$_SESSION['tracking']['lastREQ'] = '';
}
?>
Is this what you want? Maybe. lol.
Just add the code to the top of all your pages/etc. It will automatically start storing basic "tracking" info in the PHP session. Specifically, the currently requested URI (ie: /gallery/view.php?item=343) and the UNIX timestamp. It will also hold onto the "last" values so you know the last time they accessed the site and the last URI they requested.
Else where in your site, you could have your other scripts access this data to determine display of your ads/etc.
If you wanted it to be more robust in terms of tracking ALL the URIs they visit or ALL the timestamps of each visit, you could do this by modifying the code and setting each of the main keys as ARRAYS and then loading new items onto the end of the arrays. This would keep a running log of requests and request times in the PHP session. A la:
$_SESSION['tracking']['requests'][] = $_SERVER['REQUEST_URI'];
_$SESSION['tracking']['times'][] = time();
^ This would create a running log of requests and their times. You could then combine/check them against your desired ad scripting/etc.
Hope that can help you get on with what you want.
End note: You should be prepared to put a cap limit on the number of entries that will get logged. IE: remove oldest entry when 20 items get logged. Etc. Why? A busy site with lots of visitors will create a lot of session data on your server, and if this tracking is allowed to go unlimited, it will waste a lot of disk space without any real benefit.