简体   繁体   English

Codeigniter 2.2和Ion Auth重定向后丢失用户数据

[英]Codeigniter 2.2 and Ion Auth losing userdata after redirect

So, upon login, Ion Auth uses $this->session->user_setdata() to establish the session information and redirects to the main page. 因此,在登录时,Ion Auth使用$this->session->user_setdata()建立会话信息并重定向到主页。 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. 然后在MY_Controller中,我们使用Ion Auth的logging_in()方法,该方法使用$this->session->userdata('identity')检查该信息,以查看用户是否已登录。

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. 重定向之前,所有用户数据均已设置,如$this->session->all_userdata()但在进入MY_Controller时,所有用户数据均不存在,并导致应用程序重定向回登录页面。

I WAS on 2.1.4 but upgraded to 2.2 and its happening in both versions. 我在2.1.4上运行,但是升级到2.2,并且在两个版本中都发生过。

I had this exact same problem using Flexi Auth and it was completely maddening. 使用Flexi Auth时 ,我遇到了完全相同的问题,这简直令人发疯。 We found a workaround by enabling encryption of the cookies with the setting sess_encrypt_cookie in application/config/config.php . 通过在application/config/config.phpapplication/config/config.php sess_encrypt_cookie设置启用cookie加密,我们找到了一种解决方法。 (See: Session Class ). (请参阅: 会话类 )。

Stepping through our app with xdebug, we could see the PHP session getting regenerated when cookies were not encrypted. 使用xdebug逐步浏览我们的应用程序,可以看到未加密cookie时重新生成了PHP会话。 Enabling encryption of the cookies bypasses the block of code in the framework that keeps regenerating the session ID. 启用cookie的加密会绕过框架中不断重新生成会话ID的代码块。 The problem seems to be entirely contained in the CI framework with its handling of sessions. 该问题似乎完全包含在CI框架及其会话处理中。

EDIT 编辑

If it helps, here is the session configuration in our config.php : 如果有帮助,这是我们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 . sess_encrypt_cookie ,我们已更改的设置是sess_encrypt_cookie ,再从数据库驱动会话, sess_use_databaseTRUE For what it is worth, we do have both Ion Auth and Flexi Auth running in the same CI application. 物有所值,我们在同一CI应用程序中同时运行了Ion Auth和Flexi Auth。 I looked at our Ion Auth config and it is mostly the stock settings. 我查看了我们的Io​​n Auth配置,主要是库存设置。 The settings we changed wouldn't relate to the session (password length, etc.). 我们更改的设置与会话无关(密码长度等)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM