警告:session_start():无法发送会话cookie - 已发送的标头 [英] Warning: session_start(): cannot send session cookie - headers already sent by

查看:96
本文介绍了警告:session_start():无法发送会话cookie - 已发送的标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我尝试登录时收到以下错误



警告:session_start():无法发送会话cookie - 已经发送的标头(输出已启动)在/home/agarwegg/public_html/emailadmin/index.php:1)第14行的/home/agarwegg/public_html/emailadmin/index.php



警告: session_start():无法发送会话缓存限制器 - 已在第14行的/home/agarwegg/public_html/emailadmin/index.php中发送的标头(在/home/agarwegg/public_html/emailadmin/index.php:1中开始输出)



警告:无法修改标头信息 - 已经发送的标头(/home/agarwegg/public_html/emailadmin/index.php:1中的输出开始)/ home / agarwegg /第16行的public_html / emailadmin / index.php











Hello, I am getting the following error when I try to login

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/agarwegg/public_html/emailadmin/index.php:1) in /home/agarwegg/public_html/emailadmin/index.php on line 14

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/agarwegg/public_html/emailadmin/index.php:1) in /home/agarwegg/public_html/emailadmin/index.php on line 14

Warning: Cannot modify header information - headers already sent by (output started at /home/agarwegg/public_html/emailadmin/index.php:1) in /home/agarwegg/public_html/emailadmin/index.php on line 16





<!DOCTYPE html>
<?php
    $error = "";
    if(isset($_POST['username'],$_POST['password'])){
 
        /*** You can change username & password ***/
        $user = array(
                        "user" => "abc",
                        "pass"=>"def"          
                );
        $username = $_POST['username'];
        $pass = $_POST['password'];
        if($username == $user['user'] && $pass == $user['pass']){
            session_start();
            $_SESSION['simple_login'] = $username;
            header("Location: Email_Manager.php");
            exit();
        }else{
            $error = "Invalid Login Credentials";
            echo "<script>alert('".$error."'); window.history.back();</script>";
        }
    }
?>

<html>
	<head>
	    <link rel="icon" type="image/png" href="favicon.png">
	     <style>
	     

.header {
   position: absolute;
   left: 0;
   top: 0;
   width: 100%;
 /*  background-color: #4CAF50; */
   font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
   color: white;
   text-align: center;
}
.tableadjust {
   position: fixed;
   margin: auto;
    width: 60%;
   top: 30%;
   margin:auto;
}
</style>   

	<style>

	
	#grad1 {
    height: 200px;
    background: #2939B3; /* For browsers that do not support gradients */
    background: linear-gradient(to right, 	#1385CC , #2939B3); /* Standard syntax (must be last) */
	}
#emails {
    font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    border-collapse: collapse;
    width: 100%; 
    max-width: 512px;  
}

#emails td, #emails th {
    border: 0px solid #ddd;
    padding: 8px;
    color: white;
}

/* #emails tr:nth-child(even){background-color: #f2f2f2;} */

/* #emails tr:hover {background-color: #ddd;} */

#emails th {
    padding-top: 12px;
    padding-bottom: 12px;
    text-align: center;
   /* background-color: #4CAF50; */
    color: white;
  
}
input[type=text], input[type=password], input[type=search] {
      font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
    padding: 6px 10px;
    margin: 3px 0;
    box-sizing: border-box;
    border-radius: 25px;
}
    input[type=button], input[type=Submit], input[type=reset] {
        font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
     background-color: Transparent; 
    border-radius: 25px;
    border: 2px solid #FFFFFF;
    color: white;
    padding: 6px 10px;
    text-decoration: none;
    margin: 3px 2px;
    cursor: pointer;
	</style>
	<title>
	Email Management
	</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
	</head>
	<body id="grad1"><center>
	<div style="max-width: 512px; width:100%; margin: auto; top: 100px; position: relative;">
        <img src="favicon.png"></img>
	<table id="emails">
		<thead>
			<tr><th colspan=2>Login to Email Management
		</thead>
		<tbody>
			<form method=POST action="index.php">
			<tr><td>Username: <td><input placeholder="Username" name="username" type="text" style="width:100%">
			<tr><td>Password: <td><input placeholder="Password" name="password" type="password" value="" style="width:100%">
			<tr><td colspan=2><input type="submit" value="Login" style="width:100%">
		</tbody>

	</table>
<font face = "Trebuchet MS" color=white><p style="width: 100%">Powered by <a href="http://www.byteitcorp.com" style="color:white;">ByteIT Corp</a></p></font>
	</div>
	

  

	</center>
	

<div class="header">
  <p><font size=25>EMAIL MANAGER</font></p>
</div>

	</body>
	
	</html>





我的尝试:



我试过把@ob_start();在代码的开头



What I have tried:

I have tried putting @ob_start(); at the beginning of the code

推荐答案

error =;
if(isset(
error = ""; if(isset(


_POST ['username'],
_POST['username'],


_POST ['password'])){

/ ***您可以更改用户名&密码*** /
_POST['password'])){ /*** You can change username & password ***/


这篇关于警告:session_start():无法发送会话cookie - 已发送的标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆