I have a Cookie set with the name 68
and value 68, it appears in the cookies settings in the browser, but on pages it works and in others it simply does not exist
$id_imovel = (isset($_COOKIE[$id_imovel_form])) ? $_COOKIE[$id_imovel_form] : '' ;
if (empty($id_imovel) || $id_imovel == "") {
setcookie($id_imovel_form, $id_imovel_form, time()+604800);
$retorno = array('codigo' => 0, 'mensagem' => 'imóvel favoritado com sucesso');
echo json_encode($retorno);
exit();
}
$id_imovel_form
is 68.
On the real estate page it appears correctly:
foreach ($imoveis as $imoveis) {
if (isset($_COOKIE[$imoveis->id_imovel]) and $_COOKIE[$imoveis->id_imovel] != ""): ?>
<div style="background-color: #EAB346; opacity: 0.7;" onclick="favoritarImovel(<?=$imoveis->id_imovel?>,<?=$id_imovel_fav?>)" id="<?=$imoveis->id_imovel?>" class="resp"><img class="inf star" src="../img/estrela.png"></div>
<?php else: ?>
<div onclick="favoritarImovel(<?=$imoveis->id_imovel?>,<?=$id_imovel_fav?>)" id="<?=$imoveis->id_imovel?>" class="resp"><img class="inf star" src="../img/estrela.png"></div>
<?php endif;
}
On another page with the same code it does not appear, even calling directly by name:
echo $_COOKIE['68'];