0
votes

I have disabled "destryo_on_close" in codeIgniter session configuration.

I do not need it very much but for one instance.

I have put "remember me" checkbox for the user login.

As usual, when user logs in I set sessions to keep him logged in. But, if the user uncheck remember me, I have to make $this->session->userdata('email') to be destroyed on user browser close event. CodeIgniter has this option generally for all sessions which I do not want and only need it in the case user unchecks 'remember me' and only for 'email' session.

1
I'm not sure if it possible to have diffrent configs for an individuel like that, but you should really be using cookies for this. – andershagbard
Sessions only live for the browser session, so when the browser is closed the session is destroyed. It’s cookies that persist, even after the browser has been closed. – Martin Bean
No! CodeIgniter uses cookies for sessioning and that's why it gives you the ability to hold them as long as you need. – user2739275

1 Answers

0
votes

Not sure I undertand, but how about unsetting the data you need? take a look here on Removing Session Data

EDIT: I don't know how your code structure is, but maybe something like this would work:

if($this->input->post('remember_me') == 1){
    // user has clicked 'remember me'
    // your code here ... 
} else {
    // user has not clicked remember me
    $this->config->set_item('sess_expire_on_close', true);
}

I haven't tested though to see if it works, but if you read here, you can set or change the config values as you need.