警告:session_start()[function.session-start]:无法发送会话cookie - 已经发送的标头(输出开始于

时间:2015-04-03 10:52:52

标签: php session header

我有错误,如警告:session_start()[function.session-start]:无法发送会话cookie - 已经发送的标头(输出从G:\ PleskVhosts \ globaledudeals.com \ translatemasters \ list.php:1开始)在第87行的G:\ PleskVhosts \ globaledudeals.com \ translatemasters \ list.php

<?php
ob_start();
session_start(); //**---> This is 87th line**
$message="";
if(count($_POST)>0) {
$conn = mysql_connect("198.72.225.45:3360","test","xxxx");
mysql_select_db("test",$conn);
$result = mysql_query("SELECT * FROM candidate WHERE user_name='" . $_POST["userName"] . "' and pass_word = '". $_POST["password"]."'");
$row  = mysql_fetch_array($result);
if(is_array($row)) {
$_SESSION["user_id"] = $row['id'];
$_SESSION["user_name"] = $row['user_name'];
} else {
$message = "<font color='#FF0000'>Invalid Username or Password!</font>";
}
}
if(isset($_SESSION["user_id"])) {
header("Location:profile.php");
}
ob_flush();
?>  

1 个答案:

答案 0 :(得分:0)

在页面开头的第一个<?php之前查看是否有空格;如果是这样,删除该空格并查看结果...
此外,始终先在页面顶部开始会话(session_start())。