php session Cannot send session cookie -
this question has answer here:
- how fix “headers sent” error in php 11 answers
i trying solve error related session in php. please me. thankyou!
warning: session_start(): cannot send session cookie - headers sent (output started @ c:\xampp\htdocs\myfolder\login.php:117) in c:\xampp\htdocs\myfolder\login.php on line 155
warning: session_start(): cannot send session cache limiter - headers sent (output started @ c:\xampp\htdocs\myfolder\login.php:117) in c:\xampp\htdocs\myfolder\login.php on line 155
here php code:
$adm_user=$_post['username']; $adm_pass=$_post['password']; if($adm_user=="" || $adm_pass=="") { echo'fields cannot empty'; } else { $adm_login_sql="select admin_login.username, admin_login.password admin_login username='$adm_user' , password='$adm_pass'"; $adm_login_query=mysql_query($adm_login_sql); if (!$adm_login_query) { echo "error: no records found" . mysql_error(); } else { echo "query successful<br>"; $adm_login_row=mysql_fetch_array($adm_login_query); $check_uname=$adm_login_row[0]; $check_pass=$adm_login_row[1]; if($check_uname==$adm_user && $check_pass==$adm_pass) { session_start(); $_session['name']=$adm_user; header('location:admin.php'); } else { echo 'password missmatch!!!'; } } }
"headers sent"
means php
script already sent http headers
, , such can't make modifications them now.
check don't send content before calling session_start()
. better yet, make session_start()
first thing in php
file (so put @ absolute beginning, before html etc).
Comments
Post a Comment