我正在尝试在访客注册后设置cookie,但我一直收到错误:
Warning: Cannot modify header information - headers already sent by
(output started at /home/spikes/public_html/finish_register.php:1)
in /home/spikes/public_html/functions.php on line 67
functions.php第67行是一个setcookie行。
这就是finish_register.php文件的样子:
<?php
if(isset($_POST["username"]))
{
require_once('functions.php');
$error = check($_POST["username"],$_POST["password"],$_POST["email"],$_POST["firstname"],$_POST["lastname"]);
if(strlen($error) > 0)
{
echo $error;
}
else
{
echo "good!";
}
}
?>
错误说第1行第1行发送的第1行是一个php标记我错过了什么?
的functions.php:
...
function createSession($userid,$firstname)
{
$expire=time()+60*60*24*30;
setcookie("usid", $userid, $expire); //line 67
setcookie("usname", $firstname, $expire);
}
...