时间:2021-07-01 10:21:17 帮助过:23人阅读
Warning: Cannot modify header information – headers already sent by (output started at C:\xampp\htdocs\b.php:2) in … on line …
但因为当时php.ini设置成了error_reporting = E_ALL & ~E_NOTICE,于是没有任何提示,所以开发的时候还是建议设成error_reporting = E_ALL 方便观察到一些异常情况。
附一个setcookie用法实例
a.php
<?php setcookie("page", "a.php"); $page = $_COOKIE["page"] ? $_COOKIE["page"] : "unknown"; echo "From " . $page . "<br /><br />"; ?> This is a.php. Go to <a href="b.php">b.php</a>
b.php
<?php setcookie("page", "b.php"); $page = isset($_COOKIE["page"]) ? $_COOKIE["page"] : "unknown"; echo "From " . $page . "<br /><br />"; ?> This is b.php. Go to <a href="a.php">a.php</a>
以上就介绍了cookies设置 PHP setcookie设置Cookie用法及设置无效的问题,包括了cookies设置方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
相关文章:
请问setcookie不设定到期时间,设定路径该怎么写?
PHP setcookie用法
php setcookie函数失效