Have you ever fall in the problem with Codeingniter Session even for simple login? I think you have, if your client use Internet Explorer. I faced the problem many times and very tired to solve that problem but could not solve it for many times. I used DB for managing session also but no luck. Later I found the problem.
Then I found that the problem is not of the session class of Codeingniter but it is the problem of IE. CI’s session library creates standards-compliant cookies that work reliably on all web browsers except for Internet Explorer 6,7,8 and so on. The reason being, Internet Explorer doesn’t follow standards (link). Shame on IE !
The simple Solving is following:
Check your setting in Config:
– Examine your cookie settings in /application/config/config.php A CI vetran recomended removing underscores from the cookie name (link). This can be done by changing:
$config['sess_cookie_name'] = 'ci_session';
$config['sess_cookie_name'] = 'cisession';
Also remove any underscore in $config[‘cookie_prefix’] since it is prefixed to the cookie name.
Check Your Server’s Time and Timezone:
Make sure your server’s time is correct. All browsers set cookies based on the client’s time. IE on the other hand, goes by server time. If the server’s time is in the past, cookies will expire as soon as they are set thus giving the illusion that your cookie never arrived.
If you are going to start a new project:
–Don’t use CI’s session class. Just write code like you normally would outside of the CI framework. Meaning: use PHP’s native session handling functions like session_start(), unset(), session_destroy() and the $_SESSION superglobal.
– By default, PHP stores data on the server in a world-readable location, like “/tmp”.
If you must need to use Ci Session:
Go for the following class:
Directions for how to install the class in your application are also on the above wiki page. It needs to be improved. Hopefully you, the reader, can improve it over time. If you do end up improving it, please reply to this post with your updated code.