CodeIgniter函数清除会话

Ant*_*ton 1 php session codeigniter

如果我取消注释此代码,我会在网站上找到空白页面.如果我评论这个,网站工作.这是我的退出代码(会话授权):

    function exit($action='') {
    if ($action == "true") {
        echo "Exit.";
        return;
    }
    $login = $this->session->userdata('username');
    if ($login == NULL) {
        redirect('/blog/login/', 'location', '301');
    }
    $array_itmes = array('username' => "$login");
    $this->session->unset_userdata($array_items);
    redirect('/blog/exit/true/', 'location', '301');}
Run Code Online (Sandbox Code Playgroud)

正常登录后:

    $newdata = array('username' => "$name");
    $this->session->set_userdata($newdata);
Run Code Online (Sandbox Code Playgroud)

在我使用的其他行动中:

    $login = $this->session->userdata('username');
    if ($login !== NULL) {
        echo $login;
    }
Run Code Online (Sandbox Code Playgroud)

我得到了我的用户名.第一个代码中的错误在哪里?我来自俄罗斯,很抱歉英语不好.

Ant*_*ton 7

只需更换它 $this->session->sess_destroy();