session_start function causing site health errors

Home Forums All Other Themes session_start function causing site health errors

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #159404
    John BageJohn Bage
    Participant
    • Topics: 3
    • Replies: 11
    • Total: 14
    Member since: June 22, 2017

    Realestate theme causing issues on WP site health checks. I found this code and commented it out and that resolved the issue. However, I worry this may have adverse effects on the site. Can you please advise?

    I get the 3 critical issue errors below…

    An active PHP session was detected
    Performance
    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.

    The REST API encountered an error
    Performance
    The REST API is one way WordPress, and other applications, communicate with the server. One example is the block editor screen, which relies on this to display, and save, your posts and pages.
    The REST API request failed due to an error.
    Error: cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received (http_request_failed)

    Your site could not complete a loopback request
    Performance
    Loopback requests are used to run scheduled events, and are also used by the built-in editors for themes and plugins to verify code stability.
    The loopback request to your site failed, this means features relying on them are not currently working as expected.
    Error: cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received (http_request_failed)

    This is what I found to work around the error but as I mentioned above, I am not sure about any adverse affects this may have.

    File: wp-content/themes/realestate/sktestate/skt-estate/inc/class-sktestate-submission.php

    Line(s): 6

    FIND

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

    -CHANGE TO-

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

    With this not commented out, the site health report takes a long time to load. I assume this is because it has to timeout. Now with those lines commented, the site health report responds back with the report within a couple of seconds.

    #159470
    Sonl SinhaSonl Sinha
    Moderator
    • Topics: 0
    • Replies: 30977
    • Total: 30977
    Member since: August 16, 2013

    Hi,

    Kindly add this code:

    Old code

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

    Replace to this code

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

    Regards,
    Dave

    #159473
    John BageJohn Bage
    Participant
    • Topics: 3
    • Replies: 11
    • Total: 14
    Member since: June 22, 2017

    That did not make any difference. It has the same resulting error. It will only work if I comment out the “session_start” line (line 6) of that file.

    #159655
    Sonl SinhaSonl Sinha
    Moderator
    • Topics: 0
    • Replies: 30977
    • Total: 30977
    Member since: August 16, 2013

    Hi,

    File: wp-content/themes/realestate/sktestate/skt-estate/inc/class-sktestate-submission.php

    Line(s): 6 Please delete following code ::

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

    and after delete above code recheck site health. now critical issue resolved.

    Regards,
    Dave

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.