masterinex Posted August 24, 2017 Share Posted August 24, 2017 <?php $a = 1; $a = $a + 1; $expiry = new DateTime('+1year') ; setcookie( 'language' , 'EN-GB', $expiry->getTimestamp()); var_dump($_COOKIE); echo "Hello world!"; ?> When i run this in phpstorm , i am getting this output: C:\xampp\htdocs\Sandbox\index.php:11: array (size=1) 'Phpstorm-aa4c01d' => string 'cc5eb5a0-3c37-42ff-8538-e849091f48c8' (length=36) Hello world! how come var_dump does not give me the language and 'EN-GB' as output ? Quote Link to comment Share on other sites More sharing options...
Jacques1 Posted August 24, 2017 Share Posted August 24, 2017 Because $_COOKIE contains the parsed cookies from the request. It does not include new cookies you're trying to set -- which wouldn't make a lot of sense, because you have no idea whether the client will even accept your cookie. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.