Your problem is very simple.  You're beginning a new session every
execution, without checking if a session is already going.  So every time it
comes back around it's looking for the variables in the current session,
which every time just began.

Check for an existing session first like:

if(!(session_id()))
session_start();

Mike Mannakee


"Alexander Deruwe" <[EMAIL PROTECTED]> wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> I'd like to post a follow-up to my previous message on this subject.
> Please still CC me when replying, thanks.
>
> New test code:
>
> "
>  <?php
>  session_start();
>
>  if (!isset($HTTP_SESSION_VARS['counter'])) {
>      $HTTP_SESSION_VARS['counter'] = 1;
>  } else {
>      $HTTP_SESSION_VARS['counter']++;
>  }
>
>  if (!isset($counter2)) {
>      session_register('counter2');
>      $counter2 = 1;
>  } else {
>      $counter2++;
>  }
>
>  if (!isset($_SESSION['counter3'])) {
>      $_SESSION['counter3'] = 1;
>  } else {
>      $_SESSION['counter3']++;
>  }
>
>  echo(sprintf("You have visited this page %d times!",
$HTTP_SESSION_VARS['counter']) . "<br>");
>  echo(sprintf("You have visited this page %d times!", $counter2) .
"<br>");
>  echo(sprintf("You have visited this page %d times!",
$_SESSION['counter3']) . "<br>");
>  ?>
> "
>
> Tried these on PHP 4.0.6 (register_globals = On):
>     - counter: doesn't work
>     - counter1: works
>     - counter2: doesn't work (to be expected)
>
> PHP 4.2.2 (register_globals = Off):
>     None of the counters work; same when register_globals = On
>
> I'm really puzzled by this; could someone please point me in the right
> direction?
>
> --
> Alexander Deruwe
> AQS-CarControl



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to