Avatar of Richard Korts
Richard Korts
Flag for United States of America asked on

php - headers already sent

I put error_reporting(E_ALL); in the top of a php program.

I get this:

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/fwsprinkler/public_html/fwsprinklercdb.info/parts_dols.php:50) in /home/fwsprinkler/public_html/fwsprinklercdb.info/config.php on line 2

Warning: Cannot modify header information - headers already sent by (output started at /home/fwsprinkler/public_html/fwsprinklercdb.info/parts_dols.php:50) in /home/fwsprinkler/public_html/fwsprinklercdb.info/config.php on line 53

Attached are 3 scripts; the top of the one being executes, part_dols.php & config.php (courtesy of an EE expert).

I fail to see the problem.

Thanks
top-of-wo-detail.php
parts-dols.php
config.php
PHP

Avatar of undefined
Last Comment
Ray Paseur

8/22/2022 - Mon
Ray Paseur

This is such a common issue that E-E has articles explaining it and showing the solutions.  Here ya go!
https://www.experts-exchange.com/Programming/Languages/Scripting/PHP/A_4423-Warning-Cannot-modify-header-information-headers-already-sent.html
ASKER CERTIFIED SOLUTION
Dave Baldwin

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Richard Korts

ASKER
To all,

I took what Dave said & it seemed to work. I no longer got those messages.

However, what I'm trying to do, based on Ray's Remember me cookie concept, does not work.

See attached. This file is included in the main program. I want the remember me timeout set to 2 hours in the "real" case but I set it to 30 minutes for this test.

Note that if the session 'uid' is not set, & the cookie is NOT set, I am trying to redirect to index.php. It doesn't do that, it returns to the program that includes config.php.

In that (calling) program, I have the following:

include "config.php";
$cookie_name = "uuk";
if(!isset($_COOKIE['uuk'])) {
  echo 'Cookie with name "' . $cookie_name . '" does not exist...<br>';
} else {
  echo 'Cookie with name "' . $cookie_name . '" value is: ' . $_COOKIE[$cookie_name] . "<br>";
}

I waited over 30 minutes, refreshed the page. The cookie is gone, but it DOES not redirect.

Why?
config.php
SOLUTION
Ray Paseur

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23