hi. i made this script that add in a mysql database information about who have visited my website.
session_start()
if(!isset($_SESSION['log'])) {
$ip=$_SERVER['REMOTE_ADDR'];
$date=date("Y-m-d H:i:s");
$browser=$_SERVER['HTTP_USER_AGENT'];
$browser=mysql_real_escape_string($browser);
if(isset($_SESSION['nickname'])) {
$user=$_SESSION['nickname'];
} else {
$user="unknownABCD1234";
}
$insert=mysql_query("INSERT INTO views (ip, user, date, browser) VALUES ('$ip', '$user', '$date', '$browser')", $mydb);
$_SESSION['log']='logged';
$_SESSION['iplog']=$ip;
$_SESSION['datelog']=$date;
}
the problem is that it adds the referencee for each user many times (but not ever, just sometimes). example, i find on my db infos like these :
ID: 1
IP : 95.108.244.252
USER : unknownABCD1234
DATE : 2010-08-07 01:16:00
BROWSER : Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)
ID : 2
IP : 95.108.244.252
USER : unknownABCD1234
DATE : 2010-08-07 01:16:04
BROWSER : Mozilla/5.0 (compatible; YandexBot/3.0; +http://yandex.com/bots)
that's impossible no? i sure that the session during more than 4 seconds :) what happen?