| 
 Posted by Pedro Graca on 11/02/06 17:17 
Michael Windsor wrote: 
> if I [...] put "$HTTP_SESSION_VARS = $_SESSION" after  
> session_start(), it stops $_SESSION behaving properly [...] 
> 
> Could this be a bug in PHP? 
 
My PHP does not exhibit that behaviour. 
Can it be that you have /something else/ in your code responsible for 
the behaviour you describe? 
 
 
    <?php 
    session_start(); 
     
    if (rand(0, 1)) { 
     
      echo "Using copy of the \$_SESSION array...<br>\n"; 
     
      $COPY_SESSION = $_SESSION; 
      if (!isset($COPY_SESSION['count'])) { 
        $COPY_SESSION['count'] = 0; 
      } 
      $val = ++$COPY_SESSION['count']; 
      if (rand(0, 1)) { 
        echo "and not copying it back.<br>\n"; 
      } else { 
        $_SESSION = $COPY_SESSION; 
      } 
     
    } else { 
     
      if (!isset($_SESSION['count'])) { 
        $_SESSION['count'] = 0; 
      } 
      $val = ++$_SESSION['count']; 
     
    } 
     
    echo "Current value is $val.<br>\n"; 
    ?> 
 
--  
I (almost) never check the dodgeit address. 
If you *really* need to mail me, use the address in the Reply-To 
header with a message in *plain* *text* *without* *attachments*.
 
[Back to original message] 
 |