Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Run once only, not on refresh

php counter problem



2:30 am on Feb 27, 2003 (gmt 0)

10+ Year Member

I have a PHP hit counter script that uses a flat file for a hit count, the problem is that if a user hit refresh the hit count goes up!

Is there a way to make this block of code execute one time only in some sort of IF stament?

I found include_once() but that was no help.


2:56 am on Feb 27, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member

You could make a quick function that checks for a cookie, then if it is not present it sets one.

Then you increment your counter only if the cookie does not exist.


3:18 am on Feb 27, 2003 (gmt 0)

10+ Year Member

I thought of doing that after I made this post, and all is fine now!



Featured Threads

Hot Threads This Week

Hot Threads This Month