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();
}
}
?>What more should I check in order to be more reliable?