이 질문을 수천 번 보았지만 그 해결책은 없습니다.PHP setcookie()는 "헤더 정보를 수정할 수 없습니다 - 헤더가 이미 전송되었습니다"라는 경고를 표시합니다.
내 PC에서는 작동하지만 웹 호스팅에서는 작동하지 않습니다. php.ini 또는 httpd.conf와 관련이 있습니까?
<?php
ob_start();
setcookie("show","1",time() + 300);
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>UDO - Under Development Office</title>
<body>
Hello World!
</body>
</html>
나중에 편집 : (false)를 부울
및
<?php
ob_start();
var_dump(ob_get_contents());
?>
인쇄 :
<?php
var_dump(ob_get_contents());
?>
인쇄 STR ing (0) ""
Stackoverflow에 대한 질문에서이 문제가 해결되지 않았으므로이 질문은 중복되지 않습니다.
필자는이 스크립트가 PHP 5.3.6이 설치된 Mac OS X에서는 작동하지만 공유 호스트 (동일한 PHP 버전)에서는 작동하지 않는다고 주장해야합니다.
가능한 복제본 : [경고 : 헤더 정보를 수정할 수 없습니다 - 이미 보낸 헤더] (http://stackoverflow.com/questions/3190833/warning-cannot-modify-header-information-headers-already-sent) – mario