dorbmd1177 2015-11-25 07:12 采纳率: 100%
浏览 57

如何在codeigniter 3中设置会话不会在浏览器关闭时到期?

I would like to set the session in codeigniter version 3 not to expire on browser close. session should be retain for ever. Session should be destoryed when the user click the logout button. In previous version codeigniter used variable called "$config['sess_expire_on_close'] = FALSE;" but now in codeigniter version 3 we dont have that. how to set in config or create custom core controller to extend the session.

$config['sess_driver'] = 'database';
 $config['sess_use_database']   = TRUE;
$config['sess_cookie_name'] = 'ci_session';
 $config['sess_expiration'] = 60*60*24*180;
$config['sess_save_path'] = 'ci_sessions';
 $config['sess_match_ip'] = FALSE;
 $config['sess_time_to_update'] = 0;
  $config['sess_regenerate_destroy'] = FALSE;
      $config['cookie_prefix']  = '';
   $config['cookie_domain'] = '';
 $config['cookie_path']     = '/';
    $config['cookie_secure']    = FALSE;
   $config['cookie_httponly']   = FALSE;
  • 写回答

2条回答 默认 最新

  • drmeu26880 2015-11-25 07:40
    关注

    I have an answer that is not related to codeigniter.
    you may want to set session lifetime via ini

    ini_set('session.gc_maxlifetime', 3600 * 2); //two hours
    session_set_cookie_params(3600 * 2);
    session_start();
    

    also have a look here of how to combine it with CG Codeigniter increase session time out not working

    Update You can set ini variables via htaccess or VirtualHost

    评论

报告相同问题?

悬赏问题

  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染