<?php
// 1️⃣ Leggiamo il cookie (browser → server)
$cookie = $_COOKIE['utente'] ?? null;

// 2️⃣ Se NON esiste, lo creiamo (server → browser)
if (!$cookie) {
    setcookie(
        'utente',      // nome
        'Mario',       // valore
        time() + 60    // scadenza (60 secondi)
    );
    $messaggio = "🍪 Cookie CREATO dal server. Ricarica la pagina.";
} else {
    $messaggio = "🍪 Cookie RICEVUTO dal browser: " . $cookie;
}
?>
<!DOCTYPE html>
<html lang="it">
<head>
  <meta charset="UTF-8">
  <title>Cookie</title>
</head>
<body>

<h1>Cookie</h1>

<p><?= $messaggio ?></p>



</body>
</html>
