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


  • 2020-05-20 22:29:05

    javascript中为何在匿名function函数后面还外加

    它可以解释成为“匿名函数自调用”,也就是说,定义一个匿名函数,然后马上调用它(因为它是匿名的,如果不立即调用就获取不到该函数的引用了)。通常它被应用在一些大型的JS框架中(如上面所说的),因为这个匿名函数的函数体相当于提供一个匿名的名字空间,这样就不会再与用户自定义的JS函数、变量、对象发生冲突了。尽管JS没有显示地提供命名空间的定义和使用机制,但这种匿名方式却不失为是一种很好的解决命名空间问题的方法。

  • 2020-05-20 22:30:14

    js中利用prototype给类添加方法

    你可能会想,这不就是个简单的函数声明?没错,这个函数就是一个类的定义的实现。如何使用这个类呢?看下面的代码:var cls1 = new MyClass(); 这样,利用new就可以生成MyClass的一个实例了。所以在js中可以说函数就是类,类就是函数。

  • 2020-05-21 10:56:53

    fixed z-index失效

    作为一个假的前端,在调试一个页面时出现了如下bug。 左侧的菜单固定为fixed时,二级菜单无法设置有效的z-index,导致菜单隐藏在页面元素之下,明明页面元素的z-index是1,但是无论把菜单的z-index设置为多大,都不管用。