You can also see the users IP address using the REMOTE_ADDR variable which can be useful if you wish to block someone from your site.
They script below is an example of how you could log your visitors details.
//open up the log file
//write the time of access$time = date(‘H:i dS F’);
fwrite($file, ‘<b>Time:</b> $time<br/>’ ); //write the users IP address
fwrite( $file, ‘<b>Ip Address:</b> $REMOTE_ADDR<br/>’); //write out the page that sent them here
fwrite($file, ‘<b>Referer:</b> $HTTP_REFFERER<br/>’);
//write the users browser detailsfwrite( $file, ‘<b>Browser:</b> $HTTP_USER_AGENT<hr/>’);
//and finial, close the log file
When you visit log.html you may get a page like below.
Time: 19:25 22nd December
Ip Address: 127.0.0.1
Browser: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
As you can see, the user was using Internet Explorer on Windows® XP®
Some browser do not recognize the HTTP_REFFERER header and it will not be shown.
This can be very useful to track the visitors to your site and too help you analyze the type ov visitors you are receiving.
*If you are using an Unix/Linux web server then you need to create a file name log.html and chmode it to 777