Open up prepend.inc.php. We will write a function to collect tracking
information and insert it into the trackingData table.
3. Add the following logUserTrail() function in prepend.inc.php??”add it
after the debug() function definition. In the function, we insert the current
request URI, all the variables associated with it, the last page, etc. into the
table. We also save the ID of the tracking data item into the session. In the
next call to this function, when we find the tdId, we update that record
with the time spent on that page??”which will be the current time minus
accessTime for that request.
function logUserTrail()
{
$userId = isset($_SESSION['userId']) ? $_SESSION['userId'] : 0;
$page = "http://".getenv('HTTP_HOST').getenv('REQUEST_URI');
// If trackingId of last request is set, update its timeSpent
if (isset($_SESSION['tdId']))
{
$query = "UPDATE trackingData SET timeSpent =
NOW() - accessTime WHERE id = '".$_SESSION['tdId']."'";
$GLOBALS['db']->Query($query);
}
// Insert current request information in trackingData
$query = "INSERT INTO trackingData (userId, sessionId, action,
page, referer, browser, vars)
VALUES ($userId, '".
Pages:
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136