Monday, 12 September 2011

How to solve session login problem in code igniter in IE

Since the CodeIgniter sessions work fine in some IE7 browsers and fail miserably in others there’s no definite fix for this problem. One thing that might be causing it is the underscore (_) in the cookie name that stores the session variables. The default CI cookie name is ‘ci_session’. Try removing the underscore and see how that works for you (did it for me).

$config['sess_cookie_name'] = 'cisession'; // note: no more underscore

If that didn’t do the trick for you you might try checking you’re server’s time settings. When cookies are being stored they are given a lifetime. It could be that you’re server’s time is a few hours behind and thus cookies will be removed immediately since their lifetime is already over.

The last, but best thing you can do is to drop the CodeIgniter session library and start using PHP’s default session handling using session_start(), $_SESSION[], unset and session_destroy. Have a look at the CodeIgniter Native Session Library if you really need to use a library to handle your sessions.

No comments:

Post a Comment