What are common reasons for cookies not being recognized in PHP, despite being properly set?

One common reason for cookies not being recognized in PHP is that they are being set after any output has been sent to the browser. To solve this issue, make sure to set cookies before any HTML or whitespace is echoed or printed to the browser.

<?php
// Set cookie before any output
setcookie("example_cookie", "value", time() + 3600, "/");

// Output HTML or other content
?>
<!DOCTYPE html>
<html>
<head>
    <title>Cookie Example</title>
</head>
<body>
    <h1>Cookie Example</h1>
</body>
</html>