Disappearing Session Variables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
denhamd2
Forum Newbie
Posts: 12
Joined: Thu Jun 10, 2004 9:59 am

Disappearing Session Variables

Post by denhamd2 »

Just wondering could someone help?

After the user submits an order form they can view what they ordered, so they get shown the items with the quantity.

however, when they go to but a second item and go back to view their orders, all thats shown is the 2nd item with the quantity, but the previous orders without their quantities.

If someone could help me out on this I would be eternally grateful...

here is the code I'm using:

Code: Select all

<?
session_start();  
header("Cache-control: private"); 
?>
<?

foreach($_POST as $key => $val) 
{ 
$_SESSION[$key] = $val; 
}
?>
<?

if(!empty($_SESSION)) 
{ 
echo '<p>Detail:<br />'; 
foreach($_SESSION as $key => $val) 
{ 
  if(!empty($val)) 
  { 
  if(preg_match('|_q$|',$key)) echo 'Quantity: '.$val.'<br />'; 
  elseif(preg_match('||',$key)) echo 'Item: '.$val.'<br />'; 
  } 
} 
echo '</p>'; 
}
?>
Post Reply