Re: [PHP] Session variable not persisting

[email protected] (Marco Behnke)
Newsgroups php.general
Message-ID <[email protected]>
Am 18.03.13 19:46, schrieb Éric Oliver Paquette:
> 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!

Just a thought that came to my mind: Have you disabled browser caching?

And about the "push" is undefined in the logs: How do you call the
script for the first time? With or with push parameter?

-- 
Marco Behnke
Dipl. Informatiker (FH), SAE Audio Engineer Diploma
Zend Certified Engineer PHP 5.3

Tel.: 0174 / 9722336
e-Mail: [email protected]

Softwaretechnik Behnke
Heinrich-Heine-Str. 7D
21218 Seevetal

http://www.behnke.biz
signature.asc (application/pgp-signature, 946 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBAgAGBQJRR4vsAAoJEMsuiTvEJLXOBU4P/i5CMaPWe24ChixQGp59wwVb
Uh7XLWPxpi/23Ei28+6fFpKM/C32jL6FIvw4yX4fsoFHGWzPNxXjU0pFvaEx2Kwr
RYP/7VHpB7mFzVEtBgb3GEGY/5h0X/nWmIfvW6ryqVZfesuy+1rolBKe7gnBtWtt
MeZuQ/H/ZNq/WWqIoLlywpTR//VHD7o06z28AxdqxzLjFadjTPEKxwonWxqNEilL
YCD6mfE7eJYRhu8X4u81Z8T7J6aPnR2a+Naq5cgMndztr49C8ODYSH9NuYUoD6jp
GxBLKX9vlPXIaafny9x1Kr39f2OfNk5OwC0FyaoSSHMkivB48wkVTrvHvS5WuT6K
4jC936z8PpEkqlk7TiyugyzVFIacfgeVUxmobhWQ1hCcKlKAaH8zRtVP1+OIz1AC
wkuIJALIiSuJ8XLE77Sdx4TDNhf/0bem2tAzEtEKopVt0DfI9TMlL5T8vj0/vtT+
2GmvbSt6UH7bjT+K7gRrl9oM/Lzy6UMiVCrvJlKVKev8vyyC+ctlDnjbZGxhgEw6
fQGjOKZnS7HDqpFXNPimTWAKFnsRa7NSFBqYzi7WCqHQl1Lo29/6TATnT7W/kfTP
Q3onSQ52E/8WpdGjQ6Rsib3e4gapjSMQMOyuCJM62VL40tYGbHnW2L5sivp04Cn4
HVvcDZqtsUi05VQjP91/
=w0ua
-----END PGP SIGNATURE-----
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.