I am new to this and have no clue even after checking how to do this. I see codes but not sure how to implement it so it "reads" right. I found this, but nto sure how to put it correctly for it to read out ok with my counter.
setcookie ("TestCookie", $value,time()+3600); /* expire in 1 hour */
I have this counter code below, which records a count each time the person/bot visit the main index file. (ex. www.somesite.com, or to /index.php). What I want to do is to actually count the same visitor again if he/she/it visits the site 1 hour later. so basically, I don't want the counter to go up if someone or bot goes to it again in 1 sec or less period.
belows script use a db file that has some numbers for "today, yesterday, and total" through ($today, $yesterday, $total, $date, $days) and shows the output on a site through another php file.
Can anyone help me with this? I will greatly appreciate it.
Code:<?php $file_count = fopen('counter/count.db', 'rb'); $data = ''; while (!feof($file_count)) $data .= fread($file_count, 4096); fclose($file_count); list($today, $yesterday, $total, $date, $days) = split("%", $data); if ($date == date("Y m d")) $today++ ; else { $yesterday = $today; $today = 1; // $today = 1; $days++; $date = date("Y m d"); } $total++; $line = "$today%$yesterday%$total%$date%$days"; $file_count = fopen('counter/count.db', 'wb'); fwrite($file_count, $line, strlen($line)); fclose($file_count); ?>
Bookmarks