Charas-Project

Off-Topic => Really Old Stuff => Archive => PHP => Topic started by: GaryCXJk on May 01, 2004, 07:17:10 PM

Title: MVW Counter
Post by: GaryCXJk on May 01, 2004, 07:17:10 PM
Well, just a basic counter I made in PHP. Problem: no IP check.
Title:
Post by: GaryCXJk on May 01, 2004, 07:22:22 PM
Okay, update. Now it will be recorded with a cookie.
Title:
Post by: GaryCXJk on May 01, 2004, 07:26:32 PM
Okay, fix. Made a small mistake.
Title:
Post by: Alex on May 01, 2004, 07:34:08 PM
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! ;)
Title:
Post by: GaryCXJk on May 01, 2004, 07:49:43 PM
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.
Title:
Post by: Alex on May 02, 2004, 08:06:50 AM
Well, simple but functional! ;)