Jump to content

Session Handling Errors


dtrm_mora

Recommended Posts

Hi All,

 

Im building a web site and for that im in need to create sessions.

 

when ever im using the following code.. I keep getting the warning which is given afterwards.

 

code:

session_start();

include('session.php');

 

if($_SESSION['type']!="coord"){

header('Location: login.php');

}

 

warning:

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at E:\Program Files\xampp\htdocs\cse\event_coord_home.php:1) in E:\Program Files\xampp\htdocs\cse\event_coord_home.php on line 3

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at E:\Program Files\xampp\htdocs\cse\event_coord_home.php:1) in E:\Program Files\xampp\htdocs\cse\event_coord_home.php on line 3

 

Warning: Cannot modify header information - headers already sent by (output started at E:\Program Files\xampp\htdocs\cse\event_coord_home.php:1) in E:\Program Files\xampp\htdocs\cse\event_coord_home.php on line 7

 

 

 

can some one please help me this. I cant find a reason for this..

 

Cheers,

Thank you

 

Link to comment
https://forums.phpfreaks.com/topic/182760-session-handling-errors/
Share on other sites

You should have checked the topic on header errors: here.

 

What it means is that there's already output sent to the browser. Call the session header before PHP outputs any html. The problem here occurs for both session_start() and the header() function, rewrite your code if you want to use header() to redirect your user.

 

For a quick solution look at ob_start, although this isn't the way you should structure your code!

 

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.