Wednesday, December 25, 2013

Cannot add header information – headers already sent in ZenCart

This tutorial shows how to resolve the issue causing the “Cannot add header information – headers already sent” error message.

Here are other variants of this problem:
Warning: Cannot send session cookie – headers already sent
Warning: Cannot send session cache limiter – headers already sent


It often occurs in WordPress, osCommerce, Drupal and VirtueMart templates and signalizes about

an empty space or line in the file.


Solution:


For instance, if you are getting an error similar to this


Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers

already sent by (output started at /public_html/includes/application_top.php:2)

in /public_html/includes/functions/sessions.php line 102


please do the following:


1. Look for the first file mentioned in the error on your FTP and open it for editing.

In this particular case the file is called application_top.php located in the /public_html/includes/ folder (OsCommerce template). In your case the name of the file and its location are different.


2. Delete all spaces and blank lines under the last closing PHP tag ?> if there are any. Save the

changes.


3. Look for empty lines and spaces before the first opening PHP tag <?php If there are any, remove them. Save the changes.


4. Make sure there are no empty lines/spaces between the closing and the next opening PHP

tags. If there are any, remove them. Save the changes.


5. Refresh your browser window with your site opened in it to check if the problem is solved.


Important:


Even if you checked EVERYHING mentioned above, but the error still persists:


1) try another editor. Check the error file in a different problem.


For instance, Notepad in Unicode may add the byte order mark (BOM) character before <?,

which you can delete only a HEX-editor or in IDE. In DreamWeaver and Notepad it is not visible,

so make sure to save your file in UTF without BOM.


2) simply turn off this error reporting by opening the error file or your index.php file and

adding


error_reporting(E_ALL ^ E_ WARNING);


right after <?php


More details here http://php.net/manual/en/function.error-reporting.php.



Cannot add header information – headers already sent in ZenCart

No comments:

Post a Comment