我有以下错误,而在 session_start 函数之前没有输出:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /xyz_path/index.php:1) in /xyz_path/index.php on line 2
代码如下:
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>Application Jersey</title>
我也试过这段代码,错误是一样的,但会话 id 可用:
<?php
if(!session_start()){
session_start();
}
echo session_id();
?>