arrays - PHP: Save variables into a SESSION? -


i want save data session can modified user(as primitive shopping cart), need light in here.

a) information comes post form.

b) output should this:

shoping list 1. coffe 5 units, 6 usd. 2. banana 3 units, 3 usd. 3. etc (the list can infinite) 

c) current code, can see there no session. , need user able add more items.

 <?php  //variables $item= $_post['item']; $quantity= $_post['quantity']; $code= $_post['code'];   //list $articulos = array(    'pinaple' => 1, 'banana' => 2, 'aple' => 3,    'milk' => 1, 'coffe' => 3, 'butter' => 1,   'bread' => 2, 'juice' => 1, 'coconuts' => 1,   'yogurt' => 2, 'beer' => 1, 'wine' => 6,   );  //price $price = $items[$item] * $quantity;  //shoping list  echo  "<b>shopping list</b></br>";   echo "1. ".$item." ".$quantity." units".", ".$price." usd.";  //back index echo "</br> <a href='index.html'>back index</a>";   ?> 

put session_start(); @ start of script, can put want $_session, including arrays of products.

$_session['cart'] = $whatever_variable_you_want; 

Comments