<?php
session_start();

if(isset($_POST['key'])){
  $key = $_POST['key'];

  if(isset($_POST['remove'])){
    unset($_SESSION['cart'][$key]);
  }
  elseif(isset($_POST['change'])){
    $_SESSION['cart'][$key]['qty'] += (int)$_POST['change'];
    if($_SESSION['cart'][$key]['qty'] <= 0){
      unset($_SESSION['cart'][$key]);
    }
  }
}
