session var puzzle
| From: | Kathleen Ballard | Date: | Sun, 18 Apr 2004 22:46:02 +0000 |
| Subject: | session var puzzle | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-183782@lists.php.net to get a copy of this message | ||
Dear list,
I am sorry for the second posting, but this is going
to drive me to drink something other than lattes!
I have one page, index.php. when it calls mod_sub, a
directory type of page is printed. Here I am trying
to set a session var of the most recently selected
category to allow the user to return the to same place
in the directory.
when I do this:
$_SESSION['CategoryID'] = 230; in mod_sub
then in mod_profile:
print($_SESSION['CategoryID']);
will print 230
when I do this:
$Tmp = 230;
$_SESSION['CategoryID'] = $Tmp; in mod_sub
in mod_profile:
print($_SESSION['CategoryID']);
will print 230
BUT, when I do this:
$_SESSION['CategoryID'] = $Data['ID']; in mod_sub
$_SESSION['CategoryID'] = intval($Data['ID']);
in mod_profile:
print($_SESSION['CategoryID']);
will print '' and 0
I am setting several other session variables
throughout the code without any unexpected behavior.
I have even tried changing the index to something odd
in case I am resetting 'CategoryID' somewhere and
forgotten it. But no matter what I try, once I set it
"= $Data['ID']" I get the odd result.
BTW, if I print $_SESSION['CategoryID'] from mod_sub
right after setting, it holds the expected value.
This is really frustrating, I must be missing
something basic about the way session vars can be set.
Kathleen