<?php
session_start();

// Check if the cart session variable exists
if (isset($_SESSION['cart'])) {
  // Retrieve the cart items from the session
  $cartItems = $_SESSION['cart'];

  // Send a JSON response with the cart items
  http_response_code(200);
  echo json_encode($cartItems);
} else {
  // Cart is empty or not set
  http_response_code(200);
  echo json_encode([]);
}
?>
