Magento2.4.5 Session cache limiter cannot be sent after headers have already been sent

I have seen numerous posts on Magento forums and Stackoverflow with a similar topic, where developers are complaining about the same issue.
While issues can occur on any page, the most noticeable is on the front end when the customer tries to add the product to the cart. Instead of the product being added to the cart, the page will reload without any error message, and the cart state will stay the same.

If you check the ‘var/report’ folder, you will find a lot of report files with the same message:
ErrorException: Warning: session_start(): Session cache limiter cannot be sent after headers have already been sent (/magento2/public_html/vendor/laminas/laminas-http/src/PhpEnvironment/Response.php:135)
#32 /magento2/public_html/vendor/laminas/laminas-http/src/PhpEnvironment/SessionManager.php(186): Magento\Framework\Session\SessionManager::start

Unfortunately, I have had the same issue on one of our projects.
My first thought was that there is an output (like echo, print, or something similar) in the template files of a custom theme or maybe some third-party module. Switching back to the Luma theme and turning off all third-party products didn’t help.
As a last resort, we have decided to upgrade Magento from 2.4.5-p1 to 2.4.5-p3, and the issue was gone.
After following the project for a week, there were no new complaints from customers or administrators.
It might sound like a dull solution, but it is worth trying if you can’t fix the issue in any other way.

Quickly Refresh Cache in Magento 2

If you are a developer that works with Magento 2, you surely know-how clearing cache in Magento can be a boring thing. Thanks to built-in full page cache Magento front-end works quite fast, however, in most cases, your changes will not be seen unless you don’t refresh the cache.

Even Magento will remind you to do that through a notification system when you make any significant change in the back-end.

OK, most of the developers will simply use CLI to clear cache, there are few commands that help.

Clean cache: php bin/magento cache:clean

Clean cache short version: php bin/magento c:c

Flush cache: php bin/magento cache:flush

Flush cache short version: php bin/magento c:f

In case you are not comfortable with the shell, you might need to refresh the cache from your browser. While it is just a few clicks, it will soon become boring if you have to do that several times within an hour.

But, there is a really nice solution for such a case, a small add-on for Chrome that will allow you to clear your cache in just one click.

An add-on can be installed from the link below:

Quick M2 Cache Refresh Tool

Features:

  • New refresh button on Cache Management page.
  • New keyboard shortcuts for the active Cache Management page.
  • All opened Cache Management pages are listed in the popup.
  • Quick and full refresh buttons are available in the popup.
  • Always a visible number of open Cache Management pages.

Add-on support Magento from version 2.x and Chrome from version 79.x (any way you should always allow Chrome to update itself latest version).

The add-on is made by Nikola Tujković a full-time back-end developer from SMDesign Studio, all kudos go to him. If you like add-on be sure to leave a review and share it with your friends.

Cheers 🙂

White page issue – Magento 2

Another very common issue in Magento 2 are white pages in back end, error that I resolved was related to Credit Memo functionality but similar method can be applied to similar issues as well.

To describe issue a bit more, I went to Sales > Order Management > Orders and selected order that should be refunded. Issue was found on several orders and they were made using Authorize.net or PayPal payment), so I excluded possibility that custom payment method could cause issue.

In order screen I clicked Credit Memo button and landed on white page without any error message or notification. Since there were no errors in browser console (wanted to check for java script errors), I checked var/log/systemlog file and found error log:

main.CRITICAL: Broken reference: No element found with ID ‘before.body.end’.

After checking few topics about issue and suggested solutions I decided to try simplest one, to update XML file and add missing layout parameter.

For the sake of test I deiced to edit core file at line #8:

html/vendor/magento/module-sales/view/adminhtml/layout/sales_creditmemo_index.xml

and changed original code:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

to:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">

After that change I was able to open all test orders and perform Credit Memo without any issues, also there were no errors in log files.
To prevent change to be deleted on next Magento update I suggest that you overwrite core layout file with your own.
Magento 2 devdocs provide solid guide how to do that: