Simple stat system, what to check for?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Simple stat system, what to check for?

Post 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?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Re: Simple stat system, what to check for?

Post by Burrito »

you could force them to log in then timestamp whatever you're preventing against to a database based on their user id.
Post Reply