Jump to content

Recommended Posts

Posted

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?

Posted

The page starts with...

 

<?php

//set include path

set_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 cookie

if(isset($_GET['logout']))

{

setcookie("admin", '');

}

 

//check for password

if(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.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...