Welcome to WebmasterWorld Guest from 54.196.232.162

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)

Full Member

10+ Year Member

joined:Apr 4, 2002
posts:236
votes: 0


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)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 22, 2002
posts:2546
votes: 0


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)

Full Member

10+ Year Member

joined:Apr 4, 2002
posts:236
votes: 0


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

Thanks

 

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members