Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
if( isset($_COOKIE["cl1"] ) ) { echo $_COOKIE["cl1"]; } else { setcookie("cl1","me",time()+ 3600); } if( isset($_COOKIE["cl1"] ) ) { echo "the cookie is set"; }
当我运行此页面时,页面必须显示“已设置 cookie”,但屏幕为空。为什么?
在下一个页面加载之前,cookie 将不可用。cookie 与页面请求一起发送。一个 hack 使 cookie 值将在同一页面加载的 $_COOKIE 数组中是:
setcookie("cl1","me",time()+ 3600); $_COOKIE['cl1'] = "me";