tagomago Posted November 27, 2014 Posted November 27, 2014 I seem to have another problem setting a cookie. A previously working script now shows an error... Warning: Cannot modify header information - headers already sent by (output started at /home1/tagomago/public_html/includes/constants.php:19) in /home1/tagomago/public_html/misc/admininfo/index.php on line 19 Basically I am conditioning on setting a cookie based on a constant declared with the define() function in constants.php. This has never caused an issue before but has all of a sudden shown an error. I cannot place setcookie() before constants,php as it needs to know the value of a constant, the constants file contains nothing else but predefined constants. Any ideas?
yashrs Posted November 27, 2014 Posted November 27, 2014 Could you please post your code till line 20 of /home1/tagomago/public_html/misc/admininfo/constants.php
tagomago Posted November 29, 2014 Author Posted November 29, 2014 The page starts with... <?php//set include pathset_include_path($_SERVER['DOCUMENT_ROOT'] . '/includes/'); //load libraries and class files //include_once('constants.php');include_once('admin_stats.php');include_once('admin_constants.php');include_once('dbscript.php'); //set cookieif(isset($_GET['logout'])){setcookie("admin", '');} //check for passwordif(isset($_POST['password']) && $_POST['password']==ADMIN_PASS) {setcookie("admin", ADMIN_PASS, time()+3600);} Basically constants.php and admin_constants.php contain only constants defined with define(). admin_stats.php & dbscript.php contain functions only - nothing outputted to page. Also I have to set include path otherwise I cannot import constants etc.
Byron Posted November 29, 2014 Posted November 29, 2014 This should help you to understand why it's happening with a few suggestions on how to correct it: http://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php
yashrs Posted November 29, 2014 Posted November 29, 2014 You have two blank lines at the end of file constants.php
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now