/    Sign up×
Community /Pin to ProfileBookmark

$_SESSION Variable Dying Prematurely

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 filesapache groupapachehtdocsorder-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:

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJan 14.2005 — [i]Originally posted by dmichael [/i]

[B]...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....[/B]
[/QUOTE]

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.

[code=php]
$_SESSION['package_choice'] = trim($_POST['package_choice']);
echo $_SESSION['package_choice'];
[/code]
Copy linkTweet thisAlerts:
@dmichaelauthorJan 15.2005 — 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 filesapache groupapachehtdocsorder-full-page.htm on line 334

So, this is the error I get when order-full-page.htm starts to load.

THANKS AGAIN, NogDog!!!?
Copy linkTweet thisAlerts:
@NogDogJan 15.2005 — 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.)
×

Success!

Help @dmichael spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...