setcookie()
` function to set a cookie with a test value and then check if the cookie is present in subsequent requests.<?php
// Set a test cookie with a value of "test"
setcookie("test_cookie", "test", time() + 3600);
// Check if the test cookie is set
if (isset($_COOKIE["test_cookie"])) {
echo "Cookies are enabled.";
} else {
echo "Cookies are disabled.";
}
?>
setcookie()
` function to set a cookie named "test_cookie
" with a value of "test
" and an expiration time of 1 hour from the current time (specified by `time() + 3600
`). isset()
` function and the `$_COOKIE
` superglobal array. If the cookie is set, we output "Cookies are enabled." Otherwise, we output "Cookies are disabled."