0

我试图在客人注册后设置一个 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 标签我错过了什么吗?

函数.php:

...
function createSession($userid,$firstname)
{
    $expire=time()+60*60*24*30;
    setcookie("usid", $userid, $expire); //line 67
    setcookie("usname", $firstname, $expire);
}
...
4

0 回答 0