1

I am trying to have a remember me feature in CodeIgniter. My issue is that after 2 hours or so, my sessions are expiring.

I have tried using:

$remember = $this->input->post('remember_me');
if($remember) {
    $this->session->sess_expiration = '1209600';
}

And I am suspecting its because of:

$config['sess_expiration']      = 7200;

in config.php. Maybe it's overriding the maximum session time. Any help on this will be appreciated.

user4756836
  • 1,277
  • 4
  • 20
  • 47
  • Possible duplicate of [CodeIgniter extend user's session expiration time](http://stackoverflow.com/questions/2603138/codeigniter-extend-users-session-expiration-time) – Dan Dec 26 '16 at 04:36
  • 1
    @Dan doesn't seem to answer my question – user4756836 Dec 26 '16 at 04:40
  • @Dan Can you open the question in the meantime? – user4756836 Dec 26 '16 at 04:44
  • This one I mean should answer your question http://stackoverflow.com/questions/7005808/set-session-expiration-time-manually-codeigniter – Dan Dec 26 '16 at 04:45

1 Answers1

2

Did you try like this...

$remember = $this->input->post('remember_me');
if($remember) {
    $this->session->sess_expiration = '1209600';
     $this->config->set_item('sess_expiration', 1209600);
}

If you would like to dynamically set a config item or change an existing one, you can do so using:

$this->config->set_item('item_name', 'item_value');

See more here...https://www.codeigniter.com/userguide3/libraries/config.html

Hikmat Sijapati
  • 6,869
  • 1
  • 9
  • 19