doubijiao2094 2016-03-08 09:15
浏览 38
已采纳

没有记住Ion AUTH登录的CodeIgniter

I'm working on CodeIgniter login with ION auth plugin. I don't know why, but I have this behavior: I fill login form, send it, user is matched, CI save this data into "user_data" column in default_ci_sessions table and I reload page and user is still not logged in and in table default_ci_sessions is created new row with empty "user_data" column. Do you know, where might be problem? Here is my config for sessions:

$config['sess_cookie_name']     = 'pyrocms' . (ENVIRONMENT !== 'production' ? '_' . ENVIRONMENT : '');
$config['sess_expiration']      = 0;
$config['sess_expire_on_close'] = TRUE;
$config['sess_encrypt_cookie']  = TRUE;
$config['sess_use_database']    = TRUE;
// don't change anything but the 'ci_sessions' part of this. The MSM depends on the 'default_' prefix
$config['sess_table_name']      = 'default_ci_sessions';
$config['sess_match_ip']        = TRUE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update']  = 300;

Solved. I need to set cookie settings to this:

$config['cookie_prefix']    = "";
$config['cookie_domain']    = "";
$config['cookie_path']      = "";
  • 写回答

1条回答 默认 最新

  • doujiu7680 2016-03-15 14:43
    关注

    I can see that you answered the problem yourself, but to add a solution to make it easier to find for others with the same problem, I have added it here with some more explanation for why it is the solution.

    Your Full code:

    $config['sess_cookie_name']     = 'pyrocms' . (ENVIRONMENT !== 'production' ? '_' . ENVIRONMENT : '');
    $config['sess_expiration']      = 0;
    $config['sess_expire_on_close'] = TRUE;
    $config['sess_encrypt_cookie']  = TRUE;
    $config['sess_use_database']    = TRUE;
    $config['sess_table_name']      = 'default_ci_sessions';
    $config['sess_match_ip']        = TRUE;
    $config['sess_match_useragent'] = TRUE;
    $config['sess_time_to_update']  = 300;
    
    //Added code to fix issue 
    $config['cookie_prefix']    = "";
    $config['cookie_domain']    = "";
    $config['cookie_path']      = "/";
    
    • $config['cookie_prefix'] Sets a prefix if you need to avoid collisions
    • $config['cookie_domain']; Set to .your-domain.com for site-wide cookies
    • $config['cookie_path']; Typically will be a forward slash

    setting each equal to "" pretty much makes sure that cookies are set for the entire domain.

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

报告相同问题?

悬赏问题

  • ¥15 Converting circular structure to JSON
  • ¥30 Hyper-v虚拟机相关问题,求解答。
  • ¥15 TSM320F2808PZA芯片 Bootloader
  • ¥45 谷歌浏览器出现开发者工具无法显示已创建的,但您可以调试已部署的代码。 状态代码 404, net::ERR HTTP RESPONSE CODE FAILURE
  • ¥15 如何解决蓝牙通话音频突发失真问题
  • ¥15 安装opengauss数据库报错
  • ¥15 【急】在线问答CNC雕刻机的电子电路与编程
  • ¥60 在mc68335芯片上移植ucos ii 的成功工程文件
  • ¥15 笔记本外接显示器正常,但是笔记本屏幕黑屏
  • ¥15 Python pandas