Welcome to WebmasterWorld Guest from 54.159.165.175

Forum Moderators: DixonJones & mademetop

Log files with Javascript.

   
3:58 pm on Nov 25, 2007 (gmt 0)

10+ Year Member



I saw this on this thread [webmasterworld.com...]

<?php
$uri = "http://www.mysite.com" . $_SERVER['REQUEST_URI'];
$ip = $_SERVER['REMOTE_ADDR'];
$ref = $_SERVER['HTTP_REFERER'];
$dtime = date('r');
$unixtime=time();

$line = "$unixtime;$dtime;$ip;$uri;$ref";

$f = fopen("log.log", "a");

@fwrite($f, $line . "\n");
@fclose($f);
?>

and I've got this working in a fuction in an includes file but how could i do the same with javascript? so I could enter a piece of javascript. in each file?

Thank you.

9:24 pm on Nov 30, 2007 (gmt 0)

10+ Year Member



You can't write to the server with javascript. At best, you can use Javascript to submit data to a server side script (using PHP, ASP, or some other language) and write to the filesystem in that language. But that goes beyond your basic logging. You should restrict Javascript logging to capturing data in the browser that the server can't catch on it's own, and for use with third party solutions (like Google Analytics). Just use a server side script or your server logs.

If you can't see your log and you can't use server side scripting, change your web host.

 

Featured Threads

My Threads

Hot Threads This Week

Hot Threads This Month