获取“检测到活动的 PHP 会话"wordpress 中的严重警告 [英] Getting "An active PHP session was detected" critical warning in wordpress
问题描述
PHP 会话是由 session_start() 函数调用创建的.这会干扰 REST API 和环回请求.在发出任何 HTTP 请求之前,会话应由 session_write_close() 关闭.
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.
推荐答案
在大多数情况下,上述错误的真正原因是在使用 session_start() 函数.
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 cause this issue by deactive 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();
}
然后将其更改为:
if ( !session_id() ) {
session_start( [
'read_and_close' => true,
] );
}
那么你就完成了.在大多数情况下,这将解决问题.祝你好运!
Then you are done. In most cases, this will fix the issue. Good luck!
这篇关于获取“检测到活动的 PHP 会话"wordpress 中的严重警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!