This error occurs because the session_start() function is creating a PHP session, which interferes with REST API and loopback requests in WordPress. To resolve this:

  1. Locate the session_start() code
    Search your theme or active plugins for the session_start() function. It may be in the theme’s functions.php file or in a custom plugin.
  2. Add session_write_close() after session_start()
    Ensure session_write_close() is called after each session_start() call, before making any HTTP requests. This will close the session and allow the REST API to work correctly. For example:

    session_start();
    // Your code here
    session_write_close();
  3. Use the init hook in WordPress
    If session_start() needs to be in functions.php, make sure to wrap it in the init hook and use session_write_close() like this:

    add_action('init', function() {
    if (!session_id()) {
    session_start();
    session_write_close();
    }
    });