На самом деле, это не проблема, это способ работы файлов cookie.
Cookies устанавливаются с помощью HTTP-заголовка Set-Cookie, отправляемого в HTTP.
ответ от веб-сервера.
https://en.wikipedia.org/wiki/HTTP_cookie#Implementation
Допустим, вы вызываете index.php и устанавливаете там cookie, почему он не доступен в том же PHP-скрипте? Так как сервер отправляет заголовок и тело сразу, поэтому нет «эй, сначала пошли этот заголовок куки, а затем делай другие вещи». Файл cookie получен клиентом после завершения сценария PHP и отправки его заголовка + тела.
Чтобы решить вашу проблему, вы можете сделать это так:
<?php
echo "Cookie: ".$_COOKIE['privacy_warning'];
$privacy_warning = false;
if (isset($_POST['privacy_button'])) {
setcookie('privacy_warning', true, time()+10); // 10 seconds
$privacy_warning = true;
}
if (!privacy_warning):
?>
<p class="text-center alt">We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. You can read more and make your cookie choices <a href="../privacy/" style="color:white;"><u>here</u></a>. By continuing to use this site you are giving us your consent to do this.<br></p>
<form action="index.php" method="post" >
<div class="row">
<div class="text-center large-12 columns">
<button class="button tiny success" type="submit" name="privacy_button">ACCEPT</button>
</div>
</div>
</form>
<?php
endif;
?>