RE: [PHP] PLEASE HELP! session variable fails to persist!!

From: Date: Mon, 17 Jun 2002 17:29:42 +0000
Subject: RE: [PHP] PLEASE HELP! session variable fails to persist!!
Groups: php.general 
Request: Send a blank email to php-general+get-102799@lists.php.net to get a copy of this message
> -----Original Message----- > From: Zlutarch G. [mailto:zlutarch@hotmail.com] > Sent: 15 June 2002 00:54 > > My session variables won't persist, could someone help me > with this problem? PHP version? (If <=4.0.6, $_SESSION doesn't exist.) Which Web server? Version? > I spent all day trying to figure out what is wrong, and I > still don't know > why I couldn't get it to work. Here is an example script: > <? > session_id(); > session_start(); > header("Pragma: no-cache"); > header("Refresh: 2"); > $sID=session_id(); > echo "session id: $sID<br>"; > echo "session var: ".$_SESSION["var"]."<br>"; > > fnB(); > function fnA(){ > $_SESSION["var"]=1; > } > function fnB(){ > if(isset($_SESSION["var"])){ > echo "session var is set...<br>"; > } > else{ > echo "session var is not set...<br>"; > fnA(); > echo $_SESSION["var"]; > } > } > ?> > > Here is the out put from this script: > " > session id: ee030ac6e15ea2c01e1dd4fe40f3ab30 > session var: > session var is not set... > 1 > " > The session ID is the same for a given session, that means > the server knows > its the same session. And since I get the value "1" each > time, I can see > that the $_SESSION["var"] is a global variable with a value > of "1". But it > seems that once the script is finished, this variable runs > out of scope! A > session variable should persist for the duration of the > session. It should > not run out of scope like this. Could someone with more > experience tell me > what am I doing wrong? Thanks in advance. > > Zlutarch

« previous php.general (#102799) next »