/    Sign up×
Community /Pin to ProfileBookmark

[RESOLVED] Sessions not sticking

Hi,

I have session_start() at the top of each page.

I have this code in my order_products page:

[code]

@ $numOrdered= $HTTP_GET_VARS[‘numOrdered’]; // number of last item added to cart

echo(“start numbers = $numOrdered<br>”);
if (! $numOrdered) // we are on the first record
{
$HTTP_GET_VARS[‘numOrdered’] = 0;
$HTTP_GET_VARS[‘UPC’] = array();
$HTTP_GET_VARS[‘QuantityOrdered’] = array();
$HTTP_GET_VARS[‘PriceEach’] = array();
$HTTP_GET_VARS[‘Description’] = array();

$numOrdered = $HTTP_GET_VARS[‘numOrdered’];
}

for ($i = $frm_start_record; $i <= $frm_start_record + $frm_num_of_recs_shown; $i++)
{
$name_holder = “frm_productchoice_$i”;
$qty_holder = “frm_qty_$i”;
if (${$qty_holder} > 0 )
{
echo(“We have an order for product: ${$name_holder} in the amount of ${$qty_holder} <br>”);
$HTTP_GET_VARS[‘UPC’] [$numOrdered] = ${$name_holder};
$HTTP_GET_VARS[‘QuantityOrdered’] [$numOrdered] = ${$qty_holder};
$numOrdered +=1;
$HTTP_GET_VARS[‘numOrdered’] = $numOrdered ;
}

}

echo(“total number ordered: “.$HTTP_GET_VARS[‘numOrdered’].”<br> “.$HTTP_GET_VARS[‘QuantityOrdered’] [$numOrdered].”this too”);

[/code]

But, the session variables are not sticking. The next time that i visit the page, my $HTTP_GET_VARS[‘numOrdered’]; is not set, and if i attempt to access it from another page, it isn’t set, either..

Anyone see what i am missing?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@chazzyNov 28.2006 — don't use $HTTP_GET_VARS, it's out dated.

you want to be setting values in the session array, not get.

use $_SESSION['parameter'] to store data in the session.
×

Success!

Help @mparker1113 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

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