Using a Cookie
Learn how to use cookies.
We'll cover the following...
We'll cover the following...
Array of key-value pairs
The PHP server has a built-in mechanism that takes the Cookie header from the request, processes its contents, and produces a nice array of key/value pairs.
The array is a superglobal variable, just like $_GET and $_POST.
This one is called $_COOKIE.
Let’s use the name cookie in random.php to personalize the page a bit:
Reload the page a few times until it shows a random number higher than 5, after which you should see your name on the screen.
Let’s see how it works ...