我创建了一个名为'Basic'的库,在库中我调用'ion auth'库来检查用户登录 . 它正在使用php 5,但是当在php 7上运行的应用程序用户无法登录到应用程序时 . 我在php 7上检查会话数据是否为空 . 有什么问题?

我的'Basic.php'库:

public function check_login(){
    //ajax request
    if ($this->_ci->input->is_ajax_request()) {
        if (!$this->_ci->ion_auth->logged_in())
        {
            if($this->is_pjax()){
                die('<script>alert("Anda belum login atau sesi login anda sudah habis, silahkan melakukan login ulang.");window.location.replace("'.base_url().'");</script>');
            }else{
                die(json_encode(array('status'=>false,'noty'=>'Anda belum login atau sesi login anda sudah habis, silahkan melakukan login ulang.')));
            }

        }else{
            $user_data=$this->_ci->ion_auth->user()->row();
            $user_data->grup=$this->_ci->ion_auth->get_users_groups()->row()->name;
            return $user_data;
        }
    }else{
        if (!$this->_ci->ion_auth->logged_in())
        {
            // redirect them to the login page
            redirect('login', 'refresh');
        }
        else
        {   
            $user_data=$this->_ci->ion_auth->user()->row();
            $user_data->grup=$this->_ci->ion_auth->get_users_groups()->row()->name;
            return $user_data;
        }
    }
}

我的'Auth'控制器处理登录:

public function login()
{

    if ($this->ion_auth->logged_in())
    {
        $this->index();
    }

    $this->form_validation->set_rules('email', str_replace(':', '', $this->lang->line('login_identity_email')), 'required|valid_email');
    $this->form_validation->set_rules('password', str_replace(':', '', $this->lang->line('login_password_label')), 'required');


    //ajax request
    if ($this->input->is_ajax_request()) {


        if(!$this->basic->is_pjax()){

            header('Access-Control-Allow-Origin: *');

            $res=array('status'=>false,'noty'=>'Login Gagal !');
            //sleep(10);
            $post=$this->input->post(null,true);

            if ($this->form_validation->run() == true)
            {
                if ($this->ion_auth->login($post['email'], $post['password'], false))
                {
                    $this->session->set_flashdata('message', $this->ion_auth->messages());
                    $res=array('status'=>true,'noty'=>'Login Berhasil !');
                }
            }else{
                $res['noty']=(validation_errors()) ? validation_errors() : $this->session->flashdata('message');
            }

            die(json_encode($res));
        }else{

            $this->data['title'] = $this->lang->line('login_heading');

            if ($this->form_validation->run() == true)
            {
                // check to see if the user is logging in
                // check for "remember me"
                $remember = (bool) $this->input->post('remember');

                if ($this->ion_auth->login($this->input->post('email'), $this->input->post('password'), $remember))
                {
                    $user_data=$this->ion_auth->user()->row();

                    $grupname=$this->ion_auth->get_users_groups($user_data->id)->row()->name;



                    //if the login is successful
                    //redirect them back to the home page
                    $this->session->set_flashdata('message', $this->ion_auth->messages());
                    if (!$this->ion_auth->is_admin()) // remove this elseif if you want to enable this for non-admins
                    {
                        // redirect them to the home page because they must be an administrator to view this
                        //redirect('/', 'refresh');
                        die('<script>window.location.replace("'.base_url().'dashboard");</script>');
                    }
                    else
                    {
                        die('<script>window.location.replace("'.base_url().'admin/dashboard");</script>');
                        //redirect('admin/dashboard', 'refresh');
                    }

                }
                else
                {
                    // if the login was un-successful
                    // redirect them back to the login page
                    $this->session->set_flashdata('message', $this->ion_auth->errors());
                    $this->login_view();
                    ///redirect('login', 'refresh'); // use redirects instead of loading views for compatibility with MY_Controller libraries
                }
            }
            else
            {
                // the user is not logging in so display the login page
                // set the flash data error message if there is one
                $this->login_view();

            }
        }
    }else{
        $this->login_view();
    }
}

在每个控制器上,我都将此代码添加到检查用户登录中:

$this->data['user_data']=$this->basic->check_login();