<?php
// actions/remove_from_cart.php
session_start();

if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
    header('Location: ../cart.php');
    exit;
}

$index = isset($_POST['index']) ? (int)$_POST['index'] : -1;
if (isset($_SESSION['cart'][$index])) {
    array_splice($_SESSION['cart'], $index, 1);
}
header('Location: ../cart.php');
exit;
