Page 1 of 1

Simple stat system, what to check for?

Posted: Tue Jan 20, 2009 6:56 am
by Sindarin
I've been trying to make a simple statistics system,
I set a cookie so the same user is not counted until the next 24 hours and store the info in a database,

Code: Select all

 
<?php
if (isset($_COOKIE['Visited'])) {
 
echo "You have visited us already!";
}
else
{
//set visited cookie that expires in 24 hours
$value=1;
setcookie("Visited", $value, time()+86400);
//get browser
$visitor_browser = get_browser(null, true);
$visitor_browsername = $visitor_browser[browser];
$visitor_browserversion = $visitor_browser[version];
$visitor_osname = $visitor_browser[platform];
 
$db_insert="INSERT INTO statistics 
(
visitor_browser,
visitor_browserversion,
visitor_os
)
VALUES
(
'$visitor_browsername',
'$visitor_browserversion',
'$visitor_osname'
)";
if (mysql_query($db_insert,$db_connection))
{
echo "Thanks for visiting!";
}
else
{
echo mysql_error();
}
}
?>
But that will not completely prevent the user from deleting his cookies and visiting the site again.
What more should I check in order to be more reliable?

Re: Simple stat system, what to check for?

Posted: Tue Jan 20, 2009 9:47 am
by Burrito
you could force them to log in then timestamp whatever you're preventing against to a database based on their user id.