I'm seeing a problem where some $_SESSION variables are passed from one page to another, and others are not.
The session is setup on login, with user identity held in $_SESSION["id"]. At a later date, I want to shift the identity to another, subordinate account. The change is handled by a simple form that is processed by the following snippet:
<?php
// $_SESSION["id"] is initially 2
if (isset($_POST["id"]))
{
$member = cMember::retrieve($_POST["id"]); // pull new user object from DB
$_SESSION["foo"] = $member->getField("me_id");
$_SESSION["id"] = $member->getField("me_id");
$_SESSION["bar"] = $member->getField("me_id");
redirect("blank.php?".$_SESSION["id"]); //redirect($dest);
}
?>
and $_SESSION["id"] is being properly set, because it turns up in the URL used in the redirect. It does not come across as a session variable in blank.php, however.
<?php
include("incl/page_header.php"); // includes session_start()
echo "BEFORE HACK:<br>"
print_r($_SESSION);
if (isset($_SESSION["bar"]))
$_SESSION["id"] = $_SESSION["bar"];
echo "AFTER HACK:<br>";
print_r($_SESSION);
include("incl/page_footer.php");
?>
The part that's odd? The output from blank.php is (after some editing cleanup):
BEFORE HACK:
Array ( [id] => 2 [foo] => 4455 [bar] => 4455)
AFTER HACK:
Array ( [id] => 4455 [foo] => 4455 [bar] => 4455)
In short, $_SESSION["bar"] is set and passed correctly. $_SESSION["id"] retains its old, pre-page-1 value, and doesn't reflect its new value until it is set in blank.php
Thanks for any and all ideas.
Jack