doucongmishang2385 2015-05-10 12:46
浏览 45
已采纳

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

When I click Logout, I'm unable to unset the value of the session variable. Please find my code below. I'm not sure where I'm going wrong

View:

<? 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);      
});
}

Controller

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

    $this->session->sess_destroy();
    redirect('default_controller');
}
  • 写回答

1条回答 默认 最新

  • dongyou2279 2015-05-10 13:51
    关注

    Perhaps you may wanna try the native PHP method: session_destroy();

    if still doesnt work, try accessing the SESSION global and unset from there by using whatever method you please. (Eighter unset or re-set the variable value to null)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?