這可能會被放下作爲一個「重複」,但我已閱讀作爲關於這個問題頂帖黯然把session_start();會話cookie警告
session_start();
在頂部似乎沒有對我的工作因爲這是最有建議的答案。
除了這個,我上傳這個來到我的網站約20 - 31分鐘前,但它是工作的罰款與XAMMP,可能不同的PHP版本。
這裏是我的代碼和錯誤:
Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/corrupts/public_html/index.php:29) in /home/corrupts/public_html/pages/examples/session.php on line 2
Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/corrupts/public_html/index.php:29) in /home/corrupts/public_html/pages/examples/session.php on line 2
Warning: Cannot modify header information - headers already sent by (output started at /home/corrupts/public_html/index.php:29) in /home/corrupts/public_html/pages/examples/session.php on line 33
代碼:
<?php
session_start();
include('config.php');
$user_check = $_SESSION['login_user'];
$ses_sql = mysqli_query($db,"select * from users where email = '$user_check' ");
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$login_id = $row['id'];
$login_session = $row['email'];
$login_password = $row['password'];
$rank = $row['rank'];
$join_date = $row['joined'];
$bio = $row['bio'];
$credits = $row['credits'];
$adminlevel = $row['adminlevel'];
$banned = $row['banned'];
//Get stats
$ses_sql = mysqli_query($db,"select * from stats");
$row = mysqli_fetch_array($ses_sql,MYSQLI_ASSOC);
$sales = $row['sales'];
$members = $row['members'];
$vip = $row['vips'];
if(!isset($_SESSION['login_user'])){
header("location: login.php");
}
>
你有沒有結束會議?我的猜測是你永遠不會結束會話,然後嘗試重新連接並開始一個新的會話,因爲會話永不結束,你永遠無法開始新的會話。 – Hunter
會話在您註銷時結束。 –
https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php顯然這是一個常見的php問題 – Hunter