homepage Welcome to WebmasterWorld Guest from 54.161.246.212
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Run once only, not on refresh
php counter problem
dhdweb

10+ Year Member



 
Msg#: 744 posted 2:30 am on Feb 27, 2003 (gmt 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.

 

Birdman

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 744 posted 2:56 am on Feb 27, 2003 (gmt 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.

dhdweb

10+ Year Member



 
Msg#: 744 posted 3:18 am on Feb 27, 2003 (gmt 0)

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

Thanks

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved