无法取消设置会话变量的值

时间:2015-05-10 12:46:50

标签: php codeigniter

当我单击Logout时,我无法取消设置会话变量的值。请在下面找到我的代码。我不确定我哪里出错了

查看:

<? if (!isset($this->session->userdata['user_full_name'])): ?>
<li class=""><a href="#" onclick="Login()">Login with FB</a></li>               
<? endif; ?>


<? if (isset($this->session->userdata['user_full_name'])): ?>
<li class=""><a href="#"><? echo $this->session->userdata['user_full_name']; ?></a></li>
<li class=""><a href="" onclick="Logout()">Logout</a></li>
<? endif; ?>

JS

function Logout()
{
FB.logout(function(response) {
    confirm("You have successfully logged out from FB");
    window.location.href = 'http://localhost:8080/auth/logout';
    //window.location.reload();
    console.log(response);      
});
}

控制器

function logout()
{
    $this->session->set_userdata(array(
                        'user_email'          => '',
                        'user_full_name'      => '',
                        'user_gender'         => ''                          
    ));

    $this->session->sess_destroy();
    redirect('default_controller');
}

1 个答案:

答案 0 :(得分:1)

也许您可能想尝试本机PHP方法:session_destroy();

如果仍然无效,请尝试使用您喜欢的任何方法访问SESSION全局并从那里取消设置。 (Eighter unset或将变量值重置为null)