Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag 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
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

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
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of 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
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial