Codeigniter increase session time out not working

后端 未结 2 1468
Happy的楠姐
Happy的楠姐 2021-01-07 13:30

I am new to codeigniter framework. I have a problem with session time out with pages. Right now I had enabled with the ip match ,user agent matching but doesn\'t work.

相关标签:
2条回答
  • 2021-01-07 14:22

    Finally i found the solution for the problem.

    The following ways to increase or decrease the session time out. 1.

      ini_set('session.gc_maxlifetime', 60);
    
      config->config.php
    
      $config['sess_expiration'] = ''; //in seconds.
    

    2.

     $config['sess_time_to_update'] = '' ;//in seconds (as same in sess_expiration seconds)
    

    3.If you are checking in login controller and all controller for the session data as

    $_SESSION['data'] == 'your login id or role or something
    

    .this is not getting session expired the session datas.but we need to check the check with $this->session-> userdata('your id or data need to check') and before once login successfull then need to assign the value to the session as $this->session->set_userdata('your id or something');

    while checking the session = $this->session->userdata() is empty or zero need to session_destory() and then need to redirect to your home page. Another way to increase :

    1. If your site was running in apache2 and only one website means we can directly mention the session_gc_maxtime.

    These two ways i had tried and i found the solution for the session time out.its working fine for me.

    Thanks to all.

    0 讨论(0)
  • 2021-01-07 14:23

    if you dont have ci_sessions table in your database, create it using the following script.

    CREATE TABLE IF NOT EXISTS  `ci_sessions` (
        session_id varchar(40) DEFAULT '0' NOT NULL,
        ip_address varchar(16) DEFAULT '0' NOT NULL,
        user_agent varchar(120) NOT NULL,
        last_activity int(10) unsigned DEFAULT 0 NOT NULL,
        user_data text NOT NULL,
        PRIMARY KEY (session_id),
        KEY `last_activity_idx` (`last_activity`)
    );
    

    use $this->session->set_userdata($array); to get session data. Then it should work properly

    0 讨论(0)
提交回复
热议问题