Php &引用;警告:会话启动()[function.session start]:无法发送会话cookie;错误?

Php &引用;警告:会话启动()[function.session start]:无法发送会话cookie;错误?,php,session,header,http-headers,session-cookies,Php,Session,Header,Http Headers,Session Cookies,可能重复: 不知何故,我的网站决定要崩溃,所以它就这样做了。(我的网站)不知怎的出错了 警告:session_start()[function.session start]:无法发送会话cookie-已由第1行/home/artfulme/public_html/index.php中的/home/artfulme/public_html/index.php发送的标题(输出从/home/artfulme/public_html/index.php:1开始) 警告:session_start()

可能重复:

不知何故,我的网站决定要崩溃,所以它就这样做了。(我的网站)不知怎的出错了

警告:session_start()[function.session start]:无法发送会话cookie-已由第1行/home/artfulme/public_html/index.php中的/home/artfulme/public_html/index.php发送的标题(输出从/home/artfulme/public_html/index.php:1开始)

警告:session_start()[function.session start]:无法发送session cache limiter-第1行/home/artfulme/public_html/index.php中已发送的头(输出从/home/artfulme/public_html/index.php:1开始)

我不知道发生了什么事。我去野营了,回来后每次去我的网站都会收到这个错误

以下是我的完整页面代码:

<?php session_start(); $_SESSION['loginreturn']="../index.php";  

include("scripts/mysql.php");?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- Website Stuff -->
<title>artfulME</title>
<link rel="shortcut icon" href="images/favicon.ico" />
<!-- CSS Stuff -->
<style type="text/css">
body,td,th {
    font-family: Arial, Helvetica, sans-serif;
    font-size: 16px;
    font-weight: lighter;
    color: #FFFFFF;
}
a:link {
    color: #6F8C37;
    text-decoration: none;
}
a:visited {
    text-decoration: none;
    color: #526828;
}
a:hover {
    text-decoration: underline;
    color: #ABC974;
}
a:active {
    text-decoration: none;
}
body {
    background-color: #7b7b7b;
}
</style>
<link href="css/index.css" rel="stylesheet" type="text/css" />
<link href="css/login.css" rel="stylesheet" type="text/css" />
<!-- Script Stuff -->
<script type="text/javascript">
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function showElement(obj){
    document.getElementById(obj).style.display="block"; 
}

function hideElement(obj){
    document.getElementById(obj).style.display="none";
}

function restoreValue(obj){
    if(obj.value == ""){
        obj.value = obj.defaultValue;
    }
}
function clearValue(obj){
    if(obj.value == obj.defaultValue){
        obj.value = "";
    }
}

function changeTypeToPass(obj){
    if(obj.value != obj.defaultValue){
        obj.type = "password";
    }
}
function changeTypeToText(obj){
    if(obj.value == obj.defaultValue){
        obj.type = "text";
    }
}
</script>
</head>
<body onload="MM_preloadImages('images/navi/homeover.png','images/navi/blogover.png','images/navi/mediaover.png','images/navi/blogover.PNG','images/navi/contactover.PNG')">
<div id="wrapper">
  <p style="text-align: right; text-shadow: 1px 1px #000; height: 20px; margin-right: 3px">
    <?php
        if(!isset($_SESSION['loggedin'])){
            echo "<a href='javascript:void(0);' id='showLogin' onclick=\"showElement('login');\">Login</a>\n";
        }else{
            if($_SESSION['username'] == "artfulME" || $_SESSION['username'] == "Admin"){
                echo "<strong>Hello</strong> <a href='user/index.php'>".$_SESSION['username']."</a>!&nbsp;&nbsp; <a href='post/index.php'>Post</a> | <a href='userslist/index.php'>View Users List</a> | <a href='upload/index.php'>Upload</a> | <a onclick='document.logoutform.submit(); return false;' href='javascript:void(0);'>Logout</a><form style='display:none' id='logoutform' name='logoutform'  action='scripts/logout.php'></form>";
                $_SESSION['accesstoadmin'] = 1;
            }else{
                echo "<strong>Hello</strong> <a href='user/index.php'>".$_SESSION['username']."</a>!&nbsp;&nbsp; <a onclick='document.logoutform.submit(); return false;' href='javascript:void(0);'>Logout</a><form style='display:none' id='logoutform' name='logoutform'  action='scripts/logout.php'></form>";
            }
        }
    ?></p>
  <div id="login">
    <span style="text-align: right"><p><img src="images/logintop.png" width="31" height="15" alt="logintop" /></p></span>
    <div id="cont1">
    <div style="height:5px"></div>
      <div id="cont2">
        <form id="loginform" name="loginform" method="post" action="scripts/login.php">
          <table width="100%" border="0" cellspacing="2" cellpadding="0">
            <tr>
              <td><input name="entlogin" type="text" id="entlogin" onfocus="clearValue(this);" onblur="restoreValue(this);" value="Username or Email" maxlength="50" /></td>
            </tr>
            <tr>
              <td><input name="entpass" type="text" id="entpass" onfocus="clearValue(this); changeTypeToPass(this);" onblur="restoreValue(this); changeTypeToText(this);" value="Password" maxlength="15" /></td>
            </tr>
            <tr>
              <td><a href="javascript:void(0);" onclick="document.loginform.submit(); return false;">Continue</a> or <a href="signup/index.php">Signup!</a></td>
            </tr>
            <tr>
              <td> <a href="javascript:void(0);"></a><a href="javascript:void(0);" onclick="hideElement('login');">Close</a></td>
            </tr>
          </table>
        </form>
      </div>
      <div style="height:5px"></div>
    </div>
  </div>
  <div id="header"><img src="images/logo.png" alt="artfulME" width="500" height="143" border="0" usemap="#Map" />
    <map name="Map" id="Map" title="Home | artfulME">
      <area shape="rect" coords="6,37,311,108" href="index.php" alt="Home | artfulME" />
    </map>
  </div>
  <div id="navi">
    <p><a href="index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('HOME','','images/navi/homeover.png',1)"><img src="images/navi/home.png" alt="HOME" name="HOME" width="150" height="40" border="0" id="HOME" /></a><a href="blog/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('BLOG','','images/navi/blogover.PNG',1)"><img src="images/navi/blog.png" alt="BLOG" name="BLOG" width="145" height="40" border="0" id="BLOG" /></a><a href="media/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('MEDIA','','images/navi/mediaover.PNG',1)"><img src="images/navi/media.png" alt="MEDIA" name="MEDIA" width="156" height="40" border="0" id="MEDIA" /></a><a href="contact/index.php" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('CONTACT','','images/navi/contactover.PNG',1)"><img src="images/navi/contact.png" alt="CONTACT" name="CONTACT" width="205" height="40" border="0" id="CONTACT" /></a></p>
  </div>
  <div id="left">
    <div id="block1">
      <div id="container">
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="50%"><h1>Video to be here soon!</h1></td>
          </tr>
          <tr>
            <td><p><a href="javascript:void(0);" id="showAbout" onclick="hideElement('showAbout'); showElement('moreAbout');">More about me...</a></p>
              <p id="moreAbout" style="display:none"><a href="#" onclick="showElement('showAbout'); hideElement('moreAbout');">Hide more about me...</a><br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I'm not just your ordinary person. Most male humans my age play video games, watch Youtube, eat, and sleep. I do all of those things, but I bring them up a level. I make video games (sometimes), try my best at editing Youtube videos, and I eat a lot and sleep normally.<br />
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Also, I'm a <em>very</em> good web-designer. This website is actually my best I'm sure... But, if you take a look at <a href="http://www.wildwestgraniteaz.com">www.wildwestgraniteaz.com</a> or <a href="http://villaingogh.x10.mx">villaingogh.x10.mx</a>, those are both my works.</p>
              <p>&nbsp;</p></td>
          </tr>
        </table>
      </div>
    </div>
    <div id="block3">
      <div id="container">
        <h1>Recent tweets...</h1>
        <p>
          <script src="http://widgets.twimg.com/j/2/widget.js"></script>
          <script>
new TWTR.Widget({
  version: 2,
  type: 'profile',
  rpp: 21,
  interval: 6000,
  width: 'auto',
  height: 300,
  theme: {
    shell: {
      background: '#282828',
      color: '#707071'
    },
    tweets: {
      background: '#282828',
      color: '#ffffff',
      links: '#708c37'
    }
  },
  features: {
    scrollbar: true,
    loop: false,
    live: false,
    hashtags: true,
    timestamp: true,
    avatars: false,
    behavior: 'all'
  }
}).render().setUser('FethrdWlf').start();
  </script>
        </p>
      </div>
    </div>
  </div>
  <div id="right">
    <div id="block2">
      <div id="container">
      <?php
        if(isset($_SESSION['flagged'])){
            echo $_SESSION['flagged'];
            unset($_SESSION['flagged']);
        }elseif(isset($_SESSION['notflagged'])){
            echo $_SESSION['notflagged'];
            unset($_SESSION['notflagged']);
        }
      ?>
        <h1>Most recent blog post...</h1>
        <?php include("scripts/latestpost.php"); ?>
</div>
    </div>
    <div id="block4">
      <div id="container">
        <h1>My latest Youtube video:</h1>
        <p>
          <iframe style="margin-bottom: 5px;" width="434" height="277" src="http://www.youtube.com/embed/dUyAA_CT-S0" frameborder="0" allowfullscreen></iframe>
        </p>
      </div>
    </div>
  </div>
</div>
<div id="copyright" style="background-color:#7b7b7b">
    <p style="font-size: 12px">2011 &copy; artfulME, Johnny McNeil</p></div>
</body>
</html>

巧妙
正文,td,th{
字体系列:Arial、Helvetica、无衬线字体;
字体大小:16px;
字体重量:较轻;
颜色:#FFFFFF;
}
a:链接{
颜色:#6F8C37;
文字装饰:无;
}
a:参观了{
文字装饰:无;
颜色:#526828;
}
a:悬停{
文字装饰:下划线;
颜色:#ABC974;
}
a:主动的{
文字装饰:无;
}
身体{
背景色:#7b;
}
函数MM_preload images(){//v3.0
var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();
变量i,j=d.MM\u p.length,a=MM\u.arguments;for(i=0;i\n);
}否则{
如果($_会话['username']=“artfulME”|$_会话['username']=“Admin”){
回声“你好!|| |”;
$\会话['accesstoadmin']=1;
}否则{
回声“你好”;
}
}
?>

视频很快就到了!


我不仅仅是你的普通人。我这个年龄的大多数男性都玩电子游戏、看Youtube、吃饭和睡觉。我做所有这些事情,但我把它们提高到了一个水平。我制作电子游戏(有时),尽力编辑Youtube视频,我吃得很多,睡得很正常。
另外,我是一个很好的网页设计师。我相信这个网站是我最好的…但是,如果你看一看或者,那都是我的作品

最近的推特。。。 新TWTR.Widget({ 版本:2, 键入:“配置文件”, rpp:21, 间隔时间:6000, 宽度:“自动”, 身高:300, 主题:{ 外壳:{ 背景:"282828",, 颜色:“#707071” }, 推特:{ 背景:"282828",, 颜色:“#ffffff”, 链接:“#708c37” } }, 特点:{ 滚动条:对, 循环:false, 生活:假, hashtags:true, 时间戳:对, 阿凡达:错, 行为:“全部” } }).render().setUser('FethrdWlf').start();

最近的博客文章。。。 我最新的Youtube视频:

2011年©;约翰尼·麦克尼尔·阿富尔姆


我真的不知道该怎么办。

如果没有输出到浏览器,PHP只能发送头来设置会话cookie。
您应该检查以确保php脚本开头确实没有空格。您还可以检查文件编码,这可能会使php认为有来自非打印字符的输出(如果宿主提供商升级了php或更改了默认编码,则可能会发生这种情况)。

如果你不知道这是怎么发生的,你可能想检查你的ftp日志,看看是否有人设法进入你的网站并进行了更改。

我也遇到了这个问题。我解决了这个问题,将会话放在我的编码之上,然后删除会话之间的所有空白以及与会话相关的编码。

itespace在第一个php标记之前?目前,您可以设置
错误报告(0)
来隐藏这些错误,但这并不意味着您应该这样做。这不会解决问题的原因!