"Headers have already been sent", but without "output started at ..."

Viewed 38

I get the PHP Warning: session_start(): Session cannot be started after headers have already been sent in ... error message.

I read many similar questions, but in my case, the above error message doesn't contain the (output started at /some/file.php:12) part, and without it, I'm unable to resolve the issue.

How can I get the output started at ... part added to the error message?

I use PHP 8.0 with PHP-FPM via NGINX, and the following proof-of-concept WordPress plugin triggers the error:

add_action('init', function() {
    session_start();
});

There are no other plugins activated, and I'm using the stock Twenty Twenty-Two theme.

1 Answers

Other place already output the data so session_start() caused that error.

Try replace session_start() with this one on that plugin section code.

if(!isset($_SESSION)) {
     session_start();
}
Related