PHP superglobals are populated at script start-up time, and then are NOT modified or touched by PHP again for the life of the script. That means $_COOKIE
represents the cookies that were sent to the server in the http request that fired up the script. It will NOT show any cookies you've added/changed/deleted during the life of the script. Those changes will only show up on the NEXT request.
The only exception to this is $_SESSION
, which is populated when you call session_start()
.
If you need those values to be in $_COOKIE immediately, you'll have to add them manually, e.g.
setcookie('cookie', $value, ....);
$_COOKIE['cookie'] = $value;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…