WordPress site health REST error after calling start_session
-
I have a non-WP php application that requires _SESSION and I’m passing info from WP to that application via _SESSION. I’m issuing the start_session in WP via the following:
add_action(‘init’, ‘register_my_session’); function register_my_session(){ if( ! session_id() ) { session_start(); } }
Everything seems to work great with the exception of one thing. When I look at WP Tools > Site Health I see an error
**The REST API encountered an error
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)**
If I remove just the session_start() call then the error goes away (but of course, I don’t have $_SESSION data available.)
I’ve tried moving session_start to wp-config and have also tried moving it earlier / later in the wp hooks firing order, but so far no luck.
Can anyone provide some insight as to why session_start would cause a REST error, and ideas on how to properly call session_start to get access to $_SESSION?
- The topic ‘WordPress site health REST error after calling start_session’ is closed to new replies.