我正在尝试访问我刚刚在同一个域中的其他页面中设置的cookie,但它不起作用.当我这样做时echo $_COOKIE,新页面上的数组是空的,但在创建页面上包含cookie.
这是/PROC/LOGIN.PROC.PHP中的代码
//Set the cookie for 1 year.
setcookie("username", $username, time()+365*24*60*60);
setcookie("password", $password, time()+365*24*60*60);
Run Code Online (Sandbox Code Playgroud)
这是/INC/HEADER.INC.PHP中的代码
if (isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
include("pages/user.header.pages.php");
Run Code Online (Sandbox Code Playgroud)
但是当我试图设置cookie或只在header.inc.php中显示数组时,数组为空.