PHP 7 user sessions issue - Failed to initialize storage module

2017-05-31 15:49:44


















down vote

function _open should return true to avoid this error.

It can not be null or empty whatever we use either database or file.

When we use database to store session data, we keep it blank or no Boolean return. that is the main reason for this error.

class session_handler{
    public function __construct()
    {
        session_set_save_handler(
            array($this, "_open"),
            array($this, "_close"),
            array($this, "_read"),
            array($this, "_write"),
            array($this, "_destroy"),
            array($this, "_gc")
        );
    }

    public function _open($savePath, $sessionId)
    {
        return true;
    }

    public function _close() {  }    
    public function _read($id) {  }
    public function _write($id, $data) {  }
    public function _destroy($id) {  }
    public function _gc($max) {  }}

It is only for PHP 7. I do not know it is a bug or not.

https://stackoverflow.com/questions/34125849/php-7-user-sessions-issue-failed-to-initialize-storage-module


  • 2018-09-13 22:24:04

    QQ微信登录失败,报100044错

    我用的mob的maven集成方案,说实在的从一开始用maven集成方案就是一个坑啊。每次build都会重新加载所有maven包,后来通过gradle offline总算解决了。

  • 2018-09-26 15:14:23

    PHP JSON_ENCODE 不转义中文汉字的方法

    PHP 生成JSON的时候,必须将汉字不转义为 \u开头的UNICODE数据。 网上很多,但是其实都是错误的,正确的方法是在json_encode 中加入一个参数 JSON_UNESCAPED_UNICODE

  • 2018-09-27 10:04:11

    jquery ajax超时设置

    原来ajax可以设置超时时间,那么简单,ajax还有更多功能,虽然不怎么用它,有时候还挺好用。