|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21092 No $_SESSION[] data saved
Submitted: 2002-12-19 03:26 UTC Modified: 2002-12-19 04:52 UTC
From: jeanfrederic at loiseau dot org Assigned:
Status: Closed Package: Session related
PHP Version: 4.2.3 OS: Windows XP
Private report: No CVE-ID: None
 [2002-12-19 03:26 UTC] jeanfrederic at loiseau dot org
I'm just wondering, why this code is not working


echo session_start();

if (!$_SESSION['toto']) $_SESSION['toto']=0;
else $_SESSION['toto']++;

echo "Toto = ".$_SESSION['toto'];


under Windows XP + Php 4.2.3 + Apache 1.3.24

session_start() return TRUE, and the session file is created with the correct content, but this content stay at value 0 for 'toto' between pages.

I have tried the same thing under linux... same issue...

Php Config :

Session Support enabled 

session.auto_start Off
session.cache_expire 180
session.cache_limiter nocache
session.cookie_domain no value
session.cookie_lifetime 0 
session.cookie_path / 
session.cookie_secure Off
session.entropy_file no value
session.entropy_length 0
session.gc_maxlifetime 1440
session.gc_probability 1 PHPSESSID
session.referer_check no value
session.save_handler files
session.save_path C:\winxp\temp
session.serialize_handler php
session.use_cookies On
session.use_trans_sid 0




Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-12-19 03:41 UTC] jeanfrederic at loiseau dot org
I have added 

echo "click <a href=\"test.php?".SID."\">here</a>";

in order to try to pass info in URL in case of cookie issue, and SID return... nothing... but !

echo "sessionid = ".session_id()."<br>";
echo "sessionid = ".session_name()."<br>";

return correct session id and correct session name !

So in order to replace the not working SID, I put

echo "click <a href=\"test.php?".session_name()."=".session_id()."\">here</a>";

Now the URL is showing the correct information, but still not working for $_SESSION['toto'].

 [2002-12-19 03:47 UTC]
Of course...

if $_SESSION['toto'] is 0 then

if (!$_SESSION['toto']) $_SESSION['toto'] = 0
will evaluate to:

if (!0) $_SESSION['toto'] = 0;
which is:

if (TRUE) $_SESSION['toto'] = 0;

so it will always reset the session variable to 0.

Not a bug -> bogus

 [2002-12-19 03:53 UTC] JeanFrederic at Loiseau dot org
Sorry, you're right... but in fact in my script example I missed a part, the correct used script is

if (!isset($_SESSION['toto'])) $_SESSION['toto']=0;

Sorry for confusion... (why I didn't used copy&paste ? :-))

 [2002-12-19 04:52 UTC] jeanfrederic at loiseau dot org
I found the issue... it was (it seems) a mixed between Php 4.2.3 and 4.3RC0 that made a mess... I'have completely delete Php directory and re-install 4.2.3, and now it is working fine...

Sorry for the trouble if I cause any...

PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Sun Feb 05 18:03:43 2023 UTC