PHP Program to Create and retrieve a cookie

To create and retrieve a cookie in PHP, you can use the `setcookie()` function to set the cookie, and `$_COOKIE` superglobal array to retrieve its value. Here's an example :
Program :
<?php
// Set a cookie with name "user" and value "John Doe" that expires in 1 day
setcookie("user", "John Doe", time() + (86400 * 1), "/");

// Retrieve the value of the "user" cookie
if(isset($_COOKIE["user"])) {
    echo "Welcome " . $_COOKIE["user"] . "!";
} else {
    echo "Cookie is not set!";
}
?>
In the above example, we set a cookie named "user" with value "John Doe" that expires in 1 day using the `setcookie()` function. Then, we retrieve the value of the "user" cookie using the `$_COOKIE` superglobal array and check if it is set using the `isset()` function.

If it is set, we display a welcome message with the value of the cookie. If it is not set, we display a message indicating that the cookie is not set.