<?php session_start();
//Initialise an array:
$_SESSION['cart'] = array();
// Add items with their quantities:
$_SESSION['cart']['Boxers'] = 4;
$_SESSION['cart']['T-shirts'] = 2;
$_SESSION['cart']['Socks'] = 5;
print_r($_SESSION['cart']);
// To update the quantities.
$new_quantity = 10;
$quantity = 6;
$_SESSION['cart']['Socks'] = $new_quantity;
$_SESSION['cart']['Socks'] += $quantity;
?>