February 22, 2012

Codeigniter Session not working with IE

Solution in online is: user “native session” class instead of CI_Session class

Download (Courtesy of http://codeigniter.com/wiki/Native_session)


There are many articles on this issue and many solutions suggest but the problem is the same that codeigniter is using mixture of session and cookies. Sometimes it is suggested that go to internet options and reduce privacy level or accept all cookies. Sometimes no-cache meta attributes suggested and sometimes through php header no-cache suggest. But if you are a developer so don’t leave anything vague because if you are concentrating on important modules so client will must stuck on testing login, register, logout issues whenever he will test application on IE version. After all IE is a favorite browser of a common user with excellent GUI of windows.

Known Issues:

Be careful about using the above given library because almost all the functions are same. You don’t need to change any syntax in your controllers, models, helpers etc. Just change the name of destroy() function to sess_destroy() because in native class it is destroy() instead of sess_destory. A no. of functions which are recently added in CI Session library but are not in native session library, just ignore them and if ever you will see error about those so create those functions and leave it blank or return true/false accordingly.

How to check this issue?

I am not sure about the other platforms but if you want to check codeigniter session problem with IE so do install win7 32bit with default IE 9 version. Then try to print $this->session->userdata before setting any session to it. After printing that session immediately set an array of your desired data regarding user login or whatever. Now try to print the same session values again. You will observe that nothing been changed in session, session doesn’t set as it was expected. Now try to reduce privacy level which is not recommended obviously from IE internet options, what i saw, it doesn’t work. Even i tried meta, control cache to no-cache and expires to zero as well.

Anyways, hopefully the issue will be resolved in coming versions but for now whenever you feel that project is suffering or can be suffered from this issue so don’t waste time and use native class instead of CI Session library.

I hope, this article will help those developers which are fan of CI like me but obviously IE is the most beautiful hurdle in web development 🙂 kidding…


Last updated: March 19, 2014