dtlc84438 2015-09-02 20:37
浏览 38

Codeigniter 2.2和Ion Auth在重定向后丢失userdata

So, upon login, Ion Auth uses $this->session->user_setdata() to establish the session information and redirects to the main page. Then in MY_Controller we use Ion Auth's logged_in() method which checks for that information using $this->session->userdata('identity') to see if the user is logged in.

Before the redirect all the userdata is set as seen by $this->session->all_userdata() but upon entering MY_Controller none of it is there and causes the application to redirect back to the login page.

I WAS on 2.1.4 but upgraded to 2.2 and its happening in both versions.

  • 写回答

1条回答 默认 最新

  • dongxingdu9594 2015-09-03 03:00
    关注

    I had this exact same problem using Flexi Auth and it was completely maddening. We found a workaround by enabling encryption of the cookies with the setting sess_encrypt_cookie in application/config/config.php. (See: Session Class).

    Stepping through our app with xdebug, we could see the PHP session getting regenerated when cookies were not encrypted. Enabling encryption of the cookies bypasses the block of code in the framework that keeps regenerating the session ID. The problem seems to be entirely contained in the CI framework with its handling of sessions.

    EDIT

    If it helps, here is the session configuration in our config.php:

    $config['sess_cookie_name']             = 'ci_session';
    $config['sess_expiration']              = 7200;
    $config['sess_expire_on_close'] = FALSE;
    $config['sess_encrypt_cookie']  = TRUE;
    $config['sess_use_database']    = TRUE;
    $config['sess_table_name']              = 'ci_sessions';
    $config['sess_match_ip']                = FALSE;
    $config['sess_match_useragent'] = TRUE;
    $config['sess_time_to_update']  = 300;`
    

    The settings we have changed are the sess_encrypt_cookie, as previously mentioned, plus driving the sessions from the database, sess_use_database is TRUE. For what it is worth, we do have both Ion Auth and Flexi Auth running in the same CI application. I looked at our Ion Auth config and it is mostly the stock settings. The settings we changed wouldn't relate to the session (password length, etc.).

    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向