• Resolved Rob Watson

    (@rcwatson)


    I’m getting a WordPress Site Health Status warning that appears to be related to the Login Form module:

    Warning Message:
    “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.”

    Issue Location:
    File: ultimate-elementor/modules/login-form/module.php
    Lines: 90-92
    Code:

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

    Problem:
    The Login Form module starts a PHP session but doesn’t close it before WordPress makes internal HTTP requests. This can interfere with REST API calls, loopback requests, and other WordPress operations.

    Suggested Fix:
    Add session cleanup in the Login Form module. Here’s a recommended approach:

    // In the Login Form module class, add a method to close sessions:
    private function close_session_before_http() {
        if (session_status() === PHP_SESSION_ACTIVE) {
            session_write_close();
        }
    }
    
    // In the constructor or initialization method, add hooks:
    add_action('rest_api_init', array($this, 'close_session_before_http'), 1);
    add_action('http_api_curl', array($this, 'close_session_before_http'), 1);
    add_action('shutdown', array($this, 'close_session_before_http'), 1);
    
    // Also close before any wp_redirect calls in the login form functionality

    Alternative Simple Fix:
    If the session is only needed temporarily, you could close it immediately after use:

    if ( ! session_id() && ! headers_sent() ) {
        session_start();
        // ... do session work ...
        session_write_close(); // Close when done
    }

    Impact:
    This affects WordPress Site Health and can interfere with REST API functionality, especially on sites using the Login Form widget.

    Could you please include this fix in a future update? It would ensure compatibility with WordPress’s internal HTTP operations.

Viewing 1 replies (of 1 total)
  • Plugin Support Dhruv

    (@dpandya)

    Hi @rcwatson,

    Thank you for taking the time to share your findings and suggestions regarding the Login Form module and the Site Health warning. We appreciate your attention to detail.

    It seems that you are a paid user, we are unable to provide support for premium users here on the WordPress.org forums. For further assistance and to ensure your concern is addressed promptly, please open a support ticket at https://ultimateelementor.com/contact/. Our support team will be able to review your case in detail and provide the necessary guidance.

    Thank you for your understanding.

    Best regards,
    Dhruv

Viewing 1 replies (of 1 total)

You must be logged in to reply to this topic.