Click to See Complete Forum and Search --> : $_SESSION Variable Dying Prematurely


dmichael
01-13-2005, 10:27 PM
I'm afraid no one has been able to help me with this problem, and it doesn't strike me as very complex for anyone who's a veteran with PHP. I will outline the problem again, but besides trying to simply keep alive a $_SESSION variable, I've been trying to embed it in the URL of page 3 because someone suggested this could help to keep it alive.
Page 1 is named bemine-central.htm,
Page 2 is named order-full-page.htm,
Page 3 is named payment-option-page.htm.
Here is the outline/summary of the problem:
**********************************************
I still haven't figured out what's happening as my $_SESSION variables are dying prematurely. In the process, I've tried to echo the SID, and got NOTHING! To review:

Page 1 - Hidden field (package_choice) is assigned a value via Javascript before its FORM is submitted.

Page 2 - I assign the value to a $_SESSION var using the following code:
$SESSION['package_choice'] = trim($_POST['package_choice']);
echo $SESSION['package_choice'];
The echo shows the value on page 2.

Page 3 - The following line displays NOTHING on page 3:
echo $SESSION['package_choice'];

On pages 2 & 3, I have the following at the top of both pages:
<?php
session_id();
session_start();
echo session_id();
?>
The echo displays session_id(), but on page 3 I also added this line: echo $_SESSION['package_choice']; THIS PRODUCES NOTHING!
Using the advice of SCRAGAR, I tried to ensure that the SESSION ID was made part of the URL, and based my coding on his ACTION example:
ACTION="payment-option-page.htm?from=<?php echo($PHP_SELF."&".session_id());?>"
That line of code got me the following error:
Parse error: parse error, unexpected '=' in c:\program files\apache group\apache\htdocs\order-full-page.htm on line 334

Can someone tell me what the hell is going on here? I've hit a brick wall with this stuff!!!
Thanks,
dmichael:mad:

NogDog
01-14-2005, 08:50 AM
Originally posted by dmichael
...Page 2 - I assign the value to a $_SESSION var using the following code:
$SESSION['package_choice'] = trim($_POST['package_choice']);
echo $SESSION['package_choice'];
The echo shows the value on page 2....
If this is not just a typo, it could be your problem. The assignment here is missing the underscore part of the $_SESSION array variable name.

$_SESSION['package_choice'] = trim($_POST['package_choice']);
echo $_SESSION['package_choice'];

dmichael
01-14-2005, 07:37 PM
NogDog, EXCELLENT CATCH! I've been looking at this s*** for too long now, and I needed an objective pair of eyes (it was the missing underscore). Thanks a lot!
When it comes to making the session_id() part of the URL in the ACTION= statement, can you see anything wrong with that? When the page loads, I get the parse error...NOT when I try to submit to the ACTION= page. Here it is again:

ACTION="payment-option-page.htm?from=<?php echo($PHP_SELF."&".session_id());?>"

Here's the error:
Parse error: parse error, unexpected '=' in c:\program files\apache group\apache\htdocs\order-full-page.htm on line 334
So, this is the error I get when order-full-page.htm starts to load.

THANKS AGAIN, NogDog!!!:cool:

NogDog
01-14-2005, 09:45 PM
Most likely a missing ; or un-closed parentheses in the lines just above line 334. (The parser just tells you what line it's at when it gives up, not necessarily where the mistake was.)