且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Wordpress 中使用 session_start?

更新时间:2023-12-03 23:27:52

我已将我的原始答案更改为@rafi 的正确答案(见下文).

I've changed my original answer to the correct one from @rafi (see below).

在您的functions.php文件中写入以下代码:

Write the following code in your functions.php file:

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

add_action('init', 'register_my_session');