'php setcookie returns true but $_COOKIE and $_REQUEST returns empty value

I tried to set cookie to use in browser(chrome)

In php, I wrote a code

$test = setcookie('LOGIN_TOKEN', $loginToken, time() + AUTO_LOGIN_LIMIT_TIME, '/', getCookieDomain(), isSecureCookie(), true);
getCookieDomain() = localhost
isSecureCookie() = false
AUTU_LOGIN_LIMIT_TIME = 86400 * 30
$loginToken = 7784b6511s864858a
httponly = true
path = '/'

result

$test = 1
$_COOKIE["LOGIN_TOKEN"] = empty
$_REQUEST["LOGIN_TOKEN"] = empty
$_COOKIE = []

I don't know why setcookie is success but value is empty



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source