Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/232.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 会话\u start()-无法发送会话cookie_Php_Mysql_Login - Fatal编程技术网

Php 会话\u start()-无法发送会话cookie

Php 会话\u start()-无法发送会话cookie,php,mysql,login,Php,Mysql,Login,嗨,我正在用PHP创建一个简单的注册和登录脚本,但是当我加载登录页面时,我会遇到这些错误 警告:session_start()[function.session start]:无法发送会话cookie-已由C:\Users\s14\phase2\index.php第10行中的C:\Users\s14\phase2\index.php中的(从C:\Users\s14\phase2\index.php:8开始的输出)发送的标头 警告:会话\u start()[function.session sta

嗨,我正在用PHP创建一个简单的注册和登录脚本,但是当我加载登录页面时,我会遇到这些错误

警告:session_start()[function.session start]:无法发送会话cookie-已由C:\Users\s14\phase2\index.php第10行中的C:\Users\s14\phase2\index.php中的(从C:\Users\s14\phase2\index.php:8开始的输出)发送的标头

警告:会话\u start()[function.session start]:无法发送会话缓存限制器-在第10行的C:\Users\s14\phase2\index.php中已发送的头(输出从C:\Users\s14\phase2\index.php:8开始)

从代码的第6行到第20行

<form action="index.php" method=get>
 <h1 align="center" style="color:gray" >Welcome to this simple application</h1>
<?php
error_reporting(E_ALL & ~E_NOTICE);
session_start();
if( $_SESSION["logging"])
{
     print_secure_content();
}
else {
if(!$_SESSION["logging"])
{  
$_SESSION["logging"]=true;
loginform();
}

欢迎使用这个简单的应用程序

在回显或输出之前,必须保持
会话\u start()
。在运行
session\u start()
之前输出这些HTML

您的解决方案:

<?php
/* Make sure this part is at the top */
error_reporting(E_ALL & ~E_NOTICE);
session_start();
?>
<!-- Now other -->
<form action="index.php" method=get>
 <h1 align="center" style="color:gray" >Welcome to this simple application</h1>
<?php
if( $_SESSION["logging"])
{
     print_secure_content();
}
else {
if(!$_SESSION["logging"])
{  
$_SESSION["logging"]=true;
loginform();
}
?>

欢迎使用这个简单的应用程序

必须在任何输出之前调用
会话_start()
。因此,如果将
session\u start()
调用放在任何HTML之前,应该没有问题。

谢谢,我只是把它放在HTML的顶部,错误似乎消失了。@user1281921,也把错误报告放在顶部。