Jump to content

Cannot Set Cookie


tagomago

Recommended Posts

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...