dtrm_mora Posted November 24, 2009 Share Posted November 24, 2009 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 Quote Link to comment https://forums.phpfreaks.com/topic/182760-session-handling-errors/ Share on other sites More sharing options...
Anzeo Posted November 24, 2009 Share Posted November 24, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/182760-session-handling-errors/#findComment-964615 Share on other sites More sharing options...
.josh Posted November 24, 2009 Share Posted November 24, 2009 [ot]btw your condition will always evaluate true. [/ot] Quote Link to comment https://forums.phpfreaks.com/topic/182760-session-handling-errors/#findComment-964618 Share on other sites More sharing options...
dtrm_mora Posted November 24, 2009 Author Share Posted November 24, 2009 Hi,,, Thank you for the replie.. but the problem is.. i havent set any outputs prior to those codes i have mentioned. my page starts from those codes... :( Quote Link to comment https://forums.phpfreaks.com/topic/182760-session-handling-errors/#findComment-964639 Share on other sites More sharing options...
Anzeo Posted November 24, 2009 Share Posted November 24, 2009 Can you post the complete code please? Quote Link to comment https://forums.phpfreaks.com/topic/182760-session-handling-errors/#findComment-964679 Share on other sites More sharing options...
.josh Posted November 24, 2009 Share Posted November 24, 2009 make sure there is no whitespace. above session_start(); also check session.php Quote Link to comment https://forums.phpfreaks.com/topic/182760-session-handling-errors/#findComment-964707 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.