Charas-Project
Off-Topic => Really Old Stuff => Archive => PHP => Topic started by: GaryCXJk on May 01, 2004, 07:17:10 PM
-
Well, just a basic counter I made in PHP. Problem: no IP check.
-
Okay, update. Now it will be recorded with a cookie.
-
Okay, fix. Made a small mistake.
-
Just 2 suggestions.
1) You used
if (!$_COOKIE['countercookie']) {
blahblah
setcookie("countercookie", 1, time()+3600*24);
}
Maybe better this:
if (!$_COOKIE['countercookie']) {
blahblah
setcookie("countercookie", 1);
}
This way the cookie will expire at the end of the session (when the browser closes).
After all, in a shared computer your counter would miss every other connecton during the day!
2) You may also like to know the hit rating.
if (!$_COOKIE['countercookie']) {
blahblah
setcookie("countercookie", 1, time()+3600*24);
} else {
increase the counter in a 2nd file, for example $id-hits
}
Not necessary, but fun! ;)
-
Well, I did the first change, but the second one was a bit useless.
I did however add a new file: the alternate numbers tutorial.
-
Well, simple but functional! ;)