<?php
session_start();

if (isset($_POST['id']) && isset($_POST['name'])) {
    $totId = $_POST['id'];
    $totName = $_POST['name'];
    $price = $_POST['price'];

    if (!isset($_SESSION['tots'])) {
        $_SESSION['tots'] = array();
    }

    $_SESSION['tots'][] = array('id' => $totId, 'price' => $price, 'name' => $totName);

    echo json_encode($_SESSION['tots']);
}
?>
