Eggzorcist Posted August 2, 2010 Share Posted August 2, 2010 My session start is in my session object and I include it at the top of my page prior my html code, yet I still get this warning: Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /Users/Sites/writepaps/index.php:2) in /Users/Sites/writepaps/includes/functions/sessions.php on line 11 I include the object in index line 2. and line 11 is where my session start is in my construct function <?php require_once("database.php"); require_once("user.php"); class Sessions { public $logged_in = false; protected $username; protected $password; function __construct(){ session_start(); $this->check_login(); } .... Why is this happening? Link to comment https://forums.phpfreaks.com/topic/209578-why-am-i-getting-a-session_start-header-problem/ Share on other sites More sharing options...
Yesideez Posted August 2, 2010 Share Posted August 2, 2010 Something has already been sent to the browser - even if this is just a space this will cause the page headers to be sent. Move the session_start() to the very start of the script. Link to comment https://forums.phpfreaks.com/topic/209578-why-am-i-getting-a-session_start-header-problem/#findComment-1094090 Share on other sites More sharing options...
Eggzorcist Posted August 2, 2010 Author Share Posted August 2, 2010 so I can't put it in the __construct of my function even if its included at the very top? Link to comment https://forums.phpfreaks.com/topic/209578-why-am-i-getting-a-session_start-header-problem/#findComment-1094157 Share on other sites More sharing options...
Alex Posted August 2, 2010 Share Posted August 2, 2010 No. You just can't have any whitespace before [m[session_start[/m] outside of the <?php ?> tags. I'm guessing you have a newline or two before you open your PHP tags. Link to comment https://forums.phpfreaks.com/topic/209578-why-am-i-getting-a-session_start-header-problem/#findComment-1094160 Share on other sites More sharing options...
PFMaBiSmAd Posted August 2, 2010 Share Posted August 2, 2010 output started at /Users/Sites/writepaps/index.php:2 (line 2) ^^^ It would take seeing lines 1 - 2 of index.php to determine what output you are sending that is preventing the session_start() from working. Link to comment https://forums.phpfreaks.com/topic/209578-why-am-i-getting-a-session_start-header-problem/#findComment-1094162 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.