You are here: Re: Hit Counter « All PHP « IT news, forums, messages
Re: Hit Counter

Posted by ZeldorBlat on 07/03/06 14:50

Mike wrote:
> I've seen lots of hit counters on forums but they all seem a bit long
> winded.
>
> Would anyone see a problem with this...
>
> \\ index.php
> <?php
> session_start();
> if ($_SESSION[hit] != "imhit") {
> $_SESSION[hit] = "imhit";
> \\ updated a counter in the database
> }
> ...continue with the rest of the page code.
>
> This way, if a user goes to the home page (index.php) for the first
> time, the [hit] session isn't set so it sets it and updates a counter
> in the database. If they return to the home page without closing their
> browser, the session [hit] will be set so the counter won't be updated.
>
> Obviously, once the browser is closed and re-opened, the [hit] session
> is no longer set so the counter will be updated.
>
> Am I missing something??
>
> Thanks
>
> Mike

Looks fine to me, except for some syntax:

session_start();
if (!isset($_SESSION['hit']) || $_SESSION['hit'] != "imhit") {
$_SESSION['hit'] = "imhit";
\\ updated a counter in the database
}

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация