Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/234.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP cookies没有';无法在主机上工作:000webhost_Php_Cookies_Host - Fatal编程技术网

PHP cookies没有';无法在主机上工作:000webhost

PHP cookies没有';无法在主机上工作:000webhost,php,cookies,host,Php,Cookies,Host,我正在编写一个网站,当我上传到webhost:000webhost上时。函数setcookie不起作用,阻止了标头位置。 你能帮帮我吗 PS:000webhost论坛告诉我我在这里提问 谢谢 if(!empty($_POST) && !empty($_POST['user']) && !empty($_POST['mdp'])){ $req=$DB->getDB()->prepare("SELECT * FROM comptes WHERE

我正在编写一个网站,当我上传到webhost:000webhost上时。函数setcookie不起作用,阻止了标头位置。 你能帮帮我吗

PS:000webhost论坛告诉我我在这里提问

谢谢

if(!empty($_POST) && !empty($_POST['user']) && !empty($_POST['mdp'])){
$req=$DB->getDB()->prepare("SELECT * FROM comptes WHERE (USER=:username OR MAIL=:username) AND confirmed_at IS NOT NULL");
$req->execute(['username' => $_POST['user']]);
$user= $req->fetch();
if(password_verify($_POST['mdp'], $user['MDP'])){
    $_SESSION['auth'] = $user;
    $_SESSION['flash']['success'] ="vous êtes connecté ";
    if ($_POST['remember']) {
        $remember_token= str_random(250);
        $DB->getDB()->prepare('UPDATE comptes SET remember_token= ? WHERE ID= ? ')->execute([$remember_token,$user['ID']]);
        setcookie('remember',$user['ID'].'//'.$remember_token . sha1($user['ID']. 'medicament'),time()+ 60 * 60 * 24 * 7 * 2  /*  temps cookie = 2 semaines*/ );
    }
    if ($user['role']=='client') {
        header('Location: account.php');
    }
    if($user['role']=='admin'){
        header('Location: admin.php');
    }
    if($user['role']=='cadeaux'){
        header('Location: cadeaux.php');
    }
    exit();
}else{
    $_SESSION['flash']['danger'] = "Identifiant ou mot de passe incorrect";
}
}
?>

您可以在您试图设置cookie的问题中添加一些代码吗?他们是否允许您访问错误日志?如果是,是否有任何错误记录在那里?您说cookie和标头位置都不起作用,因此它可能指向代码上方的错误,您如何确定这些东西被阻止了?此代码在本地与WampServers一起工作?您可以在问题中添加一些您的代码,从您尝试设置cookie的位置。他们是否允许您访问错误日志?如果是,是否有任何错误记录在那里?您说cookie和头位置都不工作,因此它可能指向代码上方的错误,是什么确保这些东西被阻止的?此代码在本地与wampserver一起工作