53x11.com



Cookie Counter, 1.4

Saturday, April 16th, 2005 @ 11:00 AM - code

» Download Cookie Counter, 1.4 (.zip 2kb)

Latest Version Released on August 1st, 2008

Licensed under BSD, Copyright © 2010

Cookie Counter

Do you have hit counter that miss-counts every time you refresh your web page? Are you unwilling to install a bloated multi-file script just to get an accurate hit count?

Behold! A dead-simple, minuscule sized, accurate hit counter. A PHP session (cookie) is used to determine if the site has been visited during the browser's session. The IP address of the last visitor is logged as well. Basically, you need to close your browser application, reopen it, change your IP address and revisit the web page to record a "double hit."

  1. Open counter.php with a text editor to configure the two script variables.

  2. Input the path to the counter.txt file. Input the IP addresses you wish to block from recording hits. This is useful to input your own IP address so you don't skew the hit-count with your own page views.

  3. Upload counter.php and counter.txt

  4. CHMOD counter.txt to 744.

  5. If you include this function before any headers are sent, ignore this rule. If you would like to use this counter after headers have been sent, you will need manually start session on your page. In the very FIRST line of your HTML/PHP page - above all other code, text, headers and tags, add the following:

    <?php session_start(); ?>
    
  6. To access the counter, or to add to the count. Use the following php code:

    cookie_counter();
    
  7. To return a count (number). Use the following php code:

    cookie_counter(true);
    

Article was last edited on Wednesday, August 6th, 2008 @ 2:51 PM

Version History

1.4 (08/07/31) - Minor code optimizing

1.3 (08/07/27) - Cleaned up old code, morphed script into function. Fuck the simpletons

1.2 (05/04/18) - Added IP logging and ability to block IPs

1.0 (05/04/14) - Added IP logging and ability to block IPs

Comments

Saud Iqbal says
Tuesday, August 2nd, 2005 @ 7:49 PM

I think that adding the IP to the text file is not necessary. I have changed and used the code in my website. If the user closes the browser then only the counter increases. It makes the counter very fast.

Nick says
Wednesday, August 3rd, 2005 @ 11:06 AM

All you did was remove a useful feature of the counter, IP checking. So now if I wanted to, I could visit your website, make the counter go up - close my browser, visit your website again (before anyone else) and make the counter go up and repeat this infinitely. The IP checking prevents this and is not perceivably slower or faster than your changes.

KazuyaDarklight says
Thursday, October 13th, 2005 @ 11:10 PM

Gotta love the dumb people huh Nick?

Pj says
Wednesday, September 2nd, 2009 @ 1:41 AM

Hi , I'm a novice at php and need a bit of assistance in implementing your counter. Is there any way to have the counter work from a php include? And is this the code I use to insert the counter

Thanks, -PJ

Terry says
Friday, November 13th, 2009 @ 4:46 PM

A big problem I have with hit counters is that they record hits from bots put out by Google, Yahoo, etc. which are always scanning the web. How can I only record hits from real people?

Hotel In Der Türkei says
Saturday, January 30th, 2010 @ 4:01 PM

Professional Sheet,industry population mark resource manner fall home tour survey realize appeal activity careful sing garden encourage actual follow pretty tooth on statement share drive less extend introduction entry driver loan woman promise religion measure broad northern president relatively cold bird volume consideration role work newspaper plan elderly move foreign have map contact half permanent throughout cost collect divide suppose typical replace wonderful though achieve part relatively gentleman famous south expensive really negotiation threat session argument consist effect should record hour couple lay apparent fill select off collect fix

Add Comment