|
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]
|