I'm trying to access cookie value (using $_COOKIE
) immediately after setcookie()
function in PHP. But, $_COOKIE['uname']
returns blank. Why?
Whereas, $_COOKIE['uname']
returns actual value when trying to access in next execution of the script.
setcookie('uname', $uname, time()+60*30);
echo "Cookie value: ".$_COOKIE['uname'];