PDA

View Full Version : Trying to store browser info


nauf
08-15-2002, 01:54 AM
Hey guys, I'm trying to store the browser information that I obtain when a user logs on to my web site. Can this be done with php? Basically I want to keep a running tally of the type of browsers that hit my site so that from the data I can tweak my site appropriately. Is it possible to store and write the data somewhere (to an external file, nice and neat) so I can accomplish this?

Thanks,
J

Nightfire
08-15-2002, 02:00 AM
Yeah it's possible, but I can't remember how to do it as I did it on an f2s site and lost all my scripts without doing a backup :(

Spookster
08-15-2002, 03:06 AM
Many webhosts provide an access log for you. If you wish to do this yourself you can do it like this:


<?php
$file_name = "accesslog.txt";
$data = $HTTP_USER_AGENT."\n";

$file_pointer = fopen($file_name, "a");
$lock = flock($file_pointer, LOCK_EX);

if ($lock){
fputs($file_pointer, $data);
flock($file_pointer, LOCK_UN);
}
fclose($file_pointer);
?>