Forum Moderators: DixonJones
For quick and dirty studies like this I logging beacons coded in php.
To setup logging beacons, you first have to realize how browsers work. First, they get all of the HTML code and then in sequence they get all of the sourced objects (e.g. javascript, style sheets, and most importantly images).
Since all of the HTML goes first, it's a little tricky to get start of page download with logging beacons (although it is obviously trivial in logfiles). If you really need to get the hTML downlaod you need to setup a page that only has the logging beacon and then redirect.
Instead far simple, is to put a logging beacon at the top of the page, so you at least know when all of the html is done and it has started on the sources. To get the end of the page you can call a JavaScript function with an onLoad handler in the body tag or just put a beacon at the end of the page.
Now you might be asking what do beacons look like. Beacons are images usually 1x1 pixels that call a server side script that can log events. A simple pixel just looks like:
<img src=beacon.php?param1=SomeData¶m2=someOtherData&cachebuster=randomNumber>
In this case beacon.php would be a script like:
<?
if(!empty($_GET['param1'])) $param1=addslashes($_GET['param1']);
if(!empty($_GET['param2'])) $param1=addslashes($_GET['param2']);
$uid=$_COOKIE['PHPSESSID'];
$f_out=fopen("logged_data.txt", "a");
fwrite($f_out,"$uid\t$param1\t$param2\n");
fclose($f_out);
//send a blank image
header('Content-type: image/gif');
header('Expires: Sat, 22 Apr 1978 02:19:00 GMT');
header('Cache-Control: no-cache');
header('Cache-Control: must-revalidate');
printf("%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%c%",
71,73,70,56,57,97,1,0,1,0,128,255,0,192,192,192,0,0,0,33,249,4,1,0,0,0,0,44,0,0,0,0,1,0,1,0,0,2,2,68,1,0,59);
}
?>