cfgcjm Posted January 21, 2008 Share Posted January 21, 2008 I'm getting this error: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/digiconm/public_html/Homeplate/portal/jcheck.php:1) in /home/digiconm/public_html/Homeplate/portal/jcheck.php on line 3 Warning: Cannot modify header information - headers already sent by (output started at /home/digiconm/public_html/Homeplate/portal/jcheck.php:1) in /home/digiconm/public_html/Homeplate/portal/jcheck.php on line 9 I get it after i've logged in and i click a link to a file jcheck.php which is this code: <?php /* Is User Logged In? */ session_start(); // this is just your every day page where you would want someone logged in to view the info if ($_SESSION['loggedin'] == TRUE) { // user is logged in if($_SESSION['client']==1) { header("location:ejournal.php"); exit; } if($_SESSION['client']==0) { header("location:nojournal.php"); exit; } } elseif ($_SESSION['loggedin'] == FALSE) { // user is not logged in header("location:reject.php"); exit; } ?> anyone know why Quote Link to comment https://forums.phpfreaks.com/topic/87088-solved-session-header-errors/ Share on other sites More sharing options...
Daniel0 Posted January 21, 2008 Share Posted January 21, 2008 You need to ensure that nothing (even a small space somewhere) has been output before session_start() is called. Quote Link to comment https://forums.phpfreaks.com/topic/87088-solved-session-header-errors/#findComment-445559 Share on other sites More sharing options...
cfgcjm Posted January 21, 2008 Author Share Posted January 21, 2008 nothing is there Quote Link to comment https://forums.phpfreaks.com/topic/87088-solved-session-header-errors/#findComment-445657 Share on other sites More sharing options...
mike177 Posted January 22, 2008 Share Posted January 22, 2008 I had that problem with my script. It was an error in a previous file. Also check in your php settings where the seesion.save file is and see if it need cleaning up. Quote Link to comment https://forums.phpfreaks.com/topic/87088-solved-session-header-errors/#findComment-445666 Share on other sites More sharing options...
cfgcjm Posted January 22, 2008 Author Share Posted January 22, 2008 Ok i think i found my problem but i dont know how to fix it... this is what i need my final code to be: <?php /* Is User Logged In? */ session_start(); if ($_SESSION['loggedin'] == true) { // user is logged in print 'You are logged in'; if($_SESSION['client']==1) { header("location:journal.php"); exit; } if($_SESSION['client']==0) { header("location:nojournal.php"); exit; } } elseif ($_SESSION['loggedin'] == false) { // user is not logged in header("Location:reject.php"); exit; } ?> and it works until i add more than one occurrence of header()...if i replace header with print' appropriate message'; it works fine...is there anyway to fix this... it gives me these two errors depending on the case Warning: Cannot modify header information - headers already sent by (output started at /home/digiconm/public_html/Homeplate/portal/jcheck.php:5) in /home/digiconm/public_html/Homeplate/portal/jcheck.php on line 13 or Warning: Cannot modify header information - headers already sent by (output started at /home/digiconm/public_html/Homeplate/portal/jcheck.php:5) in /home/digiconm/public_html/Homeplate/portal/jcheck.php on line 8 Quote Link to comment https://forums.phpfreaks.com/topic/87088-solved-session-header-errors/#findComment-445671 Share on other sites More sharing options...
Nhoj Posted January 22, 2008 Share Posted January 22, 2008 print 'You are logged in'; you cant print anything and then add headers afterwards... Remove the print line and it should work, (why print "you are logged in" when they are redirected anyway? Quote Link to comment https://forums.phpfreaks.com/topic/87088-solved-session-header-errors/#findComment-445680 Share on other sites More sharing options...
cfgcjm Posted January 22, 2008 Author Share Posted January 22, 2008 that did it...i actually just had that print'' there as a test Quote Link to comment https://forums.phpfreaks.com/topic/87088-solved-session-header-errors/#findComment-445681 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.