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)

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

报告相同问题?

悬赏问题

  • ¥15 preLaunchTask"C/C++: aarch64- apple-darwin22-g++-14 生成活动 文件”已终止,退出代码为-1。
  • ¥60 如何鉴定微信小程序数据被篡改过
  • ¥18 关于#贝叶斯概率#的问题:这篇文章中利用em算法求出了对数似然值作为概率表参数,然后进行概率表计算,这个概率表是怎样计算的呀
  • ¥20 C#上传XML格式数据
  • ¥15 elementui上传结合oss接口断点续传,现在只差停止上传和继续上传,各大精英看下
  • ¥100 单片机hardfaulr
  • ¥20 手机截图相片分辨率降低一半
  • ¥50 求一段sql语句,遇到小难题了,可以50米解决
  • ¥15 速求,对多种商品的购买力优化问题(用遗传算法、枚举法、粒子群算法、模拟退火算法等方法求解)
  • ¥100 速求!商品购买力最优化问题(用遗传算法求解,给出python代码)