Plugin throwing a PHP Session error in WP Health Check
-
Hello,
Perhaps you’ll remember me as the dingbat who forgot to save the plugin settings before, lol. I swear, this time I checked everything, so here it goes.
I ran into a small snag with the plugin. In the health check I get 2 critical issues dealing with an active PHP session and how it conflicts with the REST API. I don’t have many plugins installed on my site so it was not difficult to pin it down to this one.
At lines 58 and 107, ip2location-variables.php calls
session_start()
. After doing some searching, I found that apparently WP doesn’t like sessions being started like this anymore(?)I managed to “correct the problem” by editing the “offending code” from
if ( !session_id() ) { session_start(); }
to
if ( !isset( $_SESSION ) { session_start( [ 'read_and_close' => true ] ); }
Again, BOTH session_start calls had to be changed at lines 58 and 107; I suspect adding the argument to
session_start()
is the only thing that is really needed, as I am sure!session_id()
and!isset($_SESSION)
accomplish the same thing.I just updated the plugin today, when I noticed the critical issues in the Site Health screen. Both WP and the plugin are up to date.
I hope I helped and not broke the plugin or wasted your time with something this silly.
Thanks again for a great (free) plugin.
- The topic ‘Plugin throwing a PHP Session error in WP Health Check’ is closed to new replies.