In the last pair of examples where it fails, you know you are first
assigning the value of $Data['ID'] to the $_SESSION['CategoryID'] and the
over-writing that value with the value of intval($Data['ID'])?  Why are you
assigning $Data['ID'] to it if you are going to overwrite it?  If those
other tests work then I doubt that it is a session problem.  I'd
double-check to make sure that $Data['ID'] is holding a reasonable value.

-----Original Message-----
From: Kathleen Ballard [mailto:[EMAIL PROTECTED]
Sent: Sunday, April 18, 2004 6:46 PM
To: [EMAIL PROTECTED]
Subject: [PHP] session var puzzle


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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to