<?php
session_start();

if (!isset($_SESSION['user_id'])) {
    exit('Unauthorized');
}

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

if (!isset($_GET['id']) || !is_numeric($_GET['id'])) {
    exit('Invalid Request');
}

$product_id = (int)$_GET['id'];

if (isset($_SESSION['cart'][$product_id])) {
    unset($_SESSION['cart'][$product_id]);
}

echo "success";
?>