Using sessions would probably be the best way. You could also serialize an array for a url request. Or you could use curl, something like this:
$cart = array(array('smode' => 'add', 'product_no' => '16', 'qty' => 1),
array('smode' => 'add', 'product_no' => '12', 'qty' => 1),
array('smode' => 'add', 'product_no' => '13', 'qty' => 1));
$customer = 'Tom';
$post_fields = 'customer=' . $customer . '&cart=' . serialize($cart);
$ch = curl_init('http://example.com/cart_update.php');
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
curl_exec($ch);
cart_update.php:
$customer = $_POST['customer'];
$cart = unserialize($_POST['cart']);
echo $customer . ' ordered:<br />';
foreach ($cart as $item) {
if ($item['smode'] == 'add') {
echo $item['qty'] . ' of product #' . $item['product_no'] . '<br />';
}
}