Hello,
I want record the visitors ip address and how many time they access my website
but the problem that if the visitor behind firewall, so all I'll get a hundreds of visits from the same IP address
so I thought about using cookie ,
first I'll search for my cookie and if found, it add 1 to the counter
otherwise it create a new cookie
but for some reason the code not working, it always create a new cookie!!
is this the right way to do it? Thanks for your HELP
<?php
if(isset($_COOKIE['info']))
{
$cookieValue = $_COOKIE['info'];
$query = "update cookie
set count = count +1
where cookie_name='$cookieValue';";
$result = shoot_query($query);
}
else
{
$ip = getenv("REMOTE_ADDR");
$expireDate = time()+3600*24*365*10; //year
$cookieValue = uniqid (rand(),true);
$cookieValue = str_replace(".", "", "$cookieValue");
setcookie(info, $cookieValue, $expireDate);
$query = "INSERT INTO cookie (count, cookie_name, ip_address, date) VALUES
(1, '$cookieValue', '$ip', CURRENT_TIMESTAMP());";
$result = shoot_query($query);
}
?>