PHP 7.2中的自定义会话处理程序功能

问题描述 投票:0回答:1

我使用自定义方法将会话存储到MySQL表中。

private static function load()
{
    session_module_name("user");
    session_set_save_handler(['\CB\Session', 'open'],
                             ['\CB\Session', 'close'],
                             ['\CB\Session', 'read'],
                             ['\CB\Session', 'write'],
                             ['\CB\Session', 'remove'],
                             ['\CB\Session', 'gc']
                             );
    session_start();       
}

现在我不得不注释掉session_module_name("user");,因为它已经在PHP 7.2中删除了。但现在我收到了错误:

警告:session_start():无法读取会话数据:第38行/home/username/path/lib/CB/Session.php中的user(path:/ var / lib / php / sessions)

当我的函数将它们写入/读取到MySQL表时,为什么它尝试在/ var / lib / php / sessions中读/写会话。 (我的MySQL表没有填充)

session php-7.2
1个回答
0
投票

http://php.net/manual/en/function.session-start.php#120589找到了答案 我的read函数必须检查会话数据是否为null,如果是,则返回''。 我不知道这是PHP中的新东西还是bug。

© www.soinside.com 2019 - 2024. All rights reserved.