i'm trying to write a script using sessions where every time a user loads a page, a variable named 'hits' is incremented by 1, and when they leave the site, the value of 'hits' is logged in a text file. is this even possible? here's what i have so far:
<?php
session_start();
session_register('hits');
?>
<body>
<?php
$hits++;
echo ("$hits"); //just for testing purposes
//heres where i need the script to log 'hits' if the user
//leaves the site
?>
i have this on each page, but it always just echoes 1. and is there a way to wait until the user leaves the site to log the value of 'hits'? and if so, how can i do it?
thanks
~JOSH