• Gerard

    (@gerardhuguenin)


    In “Site Health” in WP 6, I had the following “critical” issue:

    1. ‘A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.

    2. While testing the REST API, an error occurred: REST API endpoint: https://website/wp-json/wp/v2/types/post?context=edit. REST API response: (http_request_failed) cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received.

    I used the String locator plugin which allows you to find a php string in the site and that’s how by typing “session_start” the search pointed to 2, 3 plugins. By disabling the Theme Tweaker plugin, the problem (1 and 2 are linked) no longer reappeared. So it is this old and no more updated plugin that is causing this problem.

    Theme Tweaker is really great for changing all site colors easily. I couldn’t find a comparable plugin. On the web, I found the page to fix this issue: https://stackoverflow.com/questions/64377032/getting-an-active-php-session-was-detected-critical-warning-in-wordpress. Especially this:

    In most cases, the real reason of the above errors is the incorrect mechanism for using PHP sessions within plugins or themes when they are using the session_start() function.

    Now you need to identify what plugin is causing this issue by deactivating your plugin one by one.

    Then in that plugin, you need to find a piece of code similar to this:

    if (!session_id()) { session_start(); }

    then change it to:

    if (!session_id()) { session_start( [ ‘read_and_close’ => true, ] ); }

    Then you are done. In most cases, this will fix the issue.

    I used the String locator plugin to locate the “session_start” string in the Theme Tweaker plugin.

    I found the “session_start” as described.

    With FileZilla, I modified it as shown.

    And indeed, the problem is solved. It no longer appears.

    This is equivalent to a Theme Tweaker update for WP 6!

    Long life to Theme Tweaker!

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter Gerard

    (@gerardhuguenin)

    I forgot to specify the file to modify. It is :
    wp-content/plugins/theme-tweaker.php.

Viewing 1 replies (of 1 total)
  • The topic ‘How to resolve a critical issue with a PHP session_start in Theme Tweaker’ is closed to new replies.