Session variable not persisting

[email protected] (Éric Oliver Paquette)
Newsgroups php.general
Message-ID <[email protected]>
Hi all, 

I'll be swift in my explanation as I can't find in any way the source of the problem; it seems to be installation-related. 

At execution, sometimes (randomly it seems at first), variable session aren't properly stored. 

=====================

First things first, about installation : 

uname -a -m -p yields :

Linux cl-t180-253cl.privatedns.com 2.6.18-308.1.1.el5 #1 SMP Wed Mar 7 04:16:51 EST 2012 x86_64 x86_64 x86_64 GNU/Linux

php -v yields :

PHP 5.3.3 (cli) (built: Jun 27 2012 12:25:48) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

=====================

To make sure it is not caused by any other part of my scripts, I just created two scripts that have replicated the problem :

SCRIPT #1 [ping.php] ################

<?php

session_start();

if(count($_SESSION['in'])==0){
    $_SESSION['in'][0]='0-initiate';
} else {
    $_SESSION['in'][] = count($_SESSION['in']).$_GET['push'];
}

if(count($_SESSION['in'])<1000){
    $rand = rand(0, 1000000);
    ?>
        <meta http-equiv="refresh" content="0;URL='pong.php?push=<?php echo $rand; ?>'">
    <?php
} else {
    var_dump($_SESSION);
}

?>

SCRIPT #2 [pong.php] ################ 

<?php

session_start();

if(count($_SESSION['in'])==0){
    $_SESSION['in'][0]='0-initiate';
} else {
    $_SESSION['in'][] = count($_SESSION['in']).$_GET['push'];
}

if(count($_SESSION['in'])<1000){
    $rand = rand(0, 1000000);
    ?>
        <meta http-equiv="refresh" content="0;URL='ping.php?push=<?php echo $rand; ?>'">
    <?php
} else {
    var_dump($_SESSION);
}

?>

##################################

In fact, when I run this on my server I randomly have empty entries in the $_SESSION array. Any thoughts on this? Is this a known bug (haven't found it…)

Thanks!
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.