PHP Session lost in CodeIgniter IE only

2020-04-30 17:44发布

问题:

I'm losting the session with CodeIgniter and only in Internet Explorer

I send an AJAX request to my first controller:

/controller/method1

In this method1, I create my session

$this->session->set_userdata('user', 1);

I send a second AJAX request 5 seconds after the first, to another method:

/controller/method2

In this method, I try to show the content of the session user

var_dump($this->session->userdata('user'));

But I got a bool(false) answer.

For information, the session library is autoloaded. In Chrome, that works good.

Do you have any idea to solve this problem?

Thanks

回答1:

Change the 'sess_cookie_name' in config from 'ci_session' to 'cisession'and sess_expiration from 7200 to 84200.



回答2:

My solution is similar to @sachin-prasad's answer. Only removing the underscore of the sess_cookie_name value will not work. You need to increase the sess_expiration as well.

I tested it in IE 11 and the session works fine.