Re: session var puzzle
| From: | Tom Rogers | Date: | Mon, 19 Apr 2004 03:25:24 +0000 |
| Subject: | Re: session var puzzle | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-183785@lists.php.net to get a copy of this message | ||
Hi,
Monday, April 19, 2004, 8:46:02 AM, you wrote:
KB> Dear list,
KB> I am sorry for the second posting, but this is going
KB> to drive me to drink something other than lattes!
KB> I have one page, index.php. when it calls mod_sub, a
KB> directory type of page is printed. Here I am trying
KB> to set a session var of the most recently selected
KB> category to allow the user to return the to same place
KB> in the directory.
KB> when I do this:
KB> $_SESSION['CategoryID'] = 230; in mod_sub
KB> then in mod_profile:
KB> print($_SESSION['CategoryID']);
KB> will print 230
KB> when I do this:
KB> $Tmp = 230;
KB> $_SESSION['CategoryID'] = $Tmp; in mod_sub
KB> in mod_profile:
KB> print($_SESSION['CategoryID']);
KB> will print 230
KB> BUT, when I do this:
KB> $_SESSION['CategoryID'] = $Data['ID']; in mod_sub
KB> $_SESSION['CategoryID'] = intval($Data['ID']);
KB> in mod_profile:
KB> print($_SESSION['CategoryID']);
KB> will print '' and 0
KB> I am setting several other session variables
KB> throughout the code without any unexpected behavior.
KB> I have even tried changing the index to something odd
KB> in case I am resetting 'CategoryID' somewhere and
KB> forgotten it. But no matter what I try, once I set it
KB> "= $Data['ID']" I get the odd result.
KB> BTW, if I print $_SESSION['CategoryID'] from mod_sub
KB> right after setting, it holds the expected value.
KB> This is really frustrating, I must be missing
KB> something basic about the way session vars can be set.
KB> Kathleen
put this at the top of each page and see if you get any undefined
variables warnings as it may be a problem of variable scope
error_reporting(E_ALL);
--
regards,
Tom