0
I have the code below:
php cookie.
$d1 = "27/07/2017";
$d2 = "27/07/2017";
setcookie("d1",$d1, (time() + (3 * 24 * 3600)));
setcookie("d2",$d2, (time() + (3 * 24 * 3600)));
$data1 = $_COOKIE["d1"];
$data2 = $_COOKIE["d2"];
?>
I want to display Cookie on this other page, but I can’t:
index php.
<?php
$data1 = $_COOKIE["d1"];
$data2 = $_COOKIE["d2"];
echo "Período informado: $data1 - $data2";
?>
The following error appears:
Notice: Undefined index: D1
Notice: Undefined index: D2
Try setting the fourth parameter of
setcookie
as"/"
.– Woss
That’s what I was missing. Thanks Anderson!
– Smoke Rohden
https://answall.com/questions/200325/problema-com-cookies-no-php/200333#200333
– user60252