Re[2]: [PHP] PLEASE HELP! session variable fails to persist!!
| From: | Stuart Dallas | Date: | Sat, 15 Jun 2002 00:34:07 +0000 |
| Subject: | Re[2]: [PHP] PLEASE HELP! session variable fails to persist!! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-102290@lists.php.net to get a copy of this message | ||
On Saturday, June 15, 2002 at 1:27:58 AM, Zlutarch G. wrote:
> I tried your idea but it didn't work. When I used session_encode(), I got
> nothing! It seems that it's not being registered as a session variable. Any
> idea why that is the case?
I hope this will help clear up any confusion.
Go here: http://www.devserver.org/test/session.php and
click on the link.
This is the code...
<?php
session_start();
$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"];
}
}
print '<br><br><a
href="'.$_SERVER['SCRIPT_NAME'].'">reload page</a>';
?>
It works. If this code doesn't work for you then it's something wrong with your
server configuration.
--
Stuart