饼干不在php aws中工作

I'm running into an issue where I can't set a cookie on an AWS EC2 instance running LAMP.

I have two simple pages, cookie.php and show_cookie.php:

cookie.php

<?php
setcookie('test', 'test', time()+36000, '/');
?>
<a href="show_cookie.php">show me the cookies!</a>

show_cookie.php

<?php
print_r($_COOKIE);
?>
<a href="cookie.php">go back</a>

When I navigate to cookie.php in Chrome and click on the link, the page echoes an empty array. Also, if I inspect Cookies, there's nothing there.

I'm running PHP 7.0.16 with Apache/2.4.25 (Amazon). This is such strange behavior. Has anyone run into something similar to point me in the right direction?

In all my experience with cookies I've always included $_SERVER['SERVER_NAME'] as a fifth argument. I don't believe you have to define $_Server. I believe it's defined during execution. If not you may have to define it as your domain or IP address.

setcookie("userid",$global['user-id'],time()+3600*2,'/',$_SERVER['SERVER_NAME']);

This is a link to the PHP guide for $_Cookies. http://php.net/manual/en/function.setcookie.php

This is a link to the PHP guide for $_Server. http://php.net/manual/en/reserved.variables.server.php

Domain:

The (sub)domain that the cookie is available to. Setting this to a subdomain (such as 'www.example.com') will make the cookie available to that subdomain and all other sub-domains of it (i.e. w2.www.example.com). To make the cookie available to the whole domain (including all subdomains of it), simply set the value to the domain name ('example.com', in this case).