Jump to content

[SOLVED] Session & header errors


cfgcjm

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/87088-solved-session-header-errors/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.