(PHP 4 >= 4.1.0, PHP 5, PHP 7, PHP 8)
$_COOKIE — HTTP Cookies
An associative array of variables passed to the current script via HTTP Cookies.
Example #1 $_COOKIE example
<?php
echo 'Hello ' . htmlspecialchars($_COOKIE["name"]) . '!';
?>
Assuming the "name" cookie has been set earlier
Il precedente esempio visualizzerà qualcosa simile a:
Hello Hannes!
Nota:
Questa è una variabile 'superglobale', o automaticamente global. Ciò semplicemente significa che è visibile in tutti gli ambiti in uno script. Non è necessario dichiararla come global $variable; per accedervi da funzioni o metodi.