Session lost after redirect in Codeigniter Session lost after redirect in Codeigniter codeigniter codeigniter

Session lost after redirect in Codeigniter


I have the exact same problem and here's what I do.First, go to file system/libraries/Session/Session.php. Comment session_start(); on line 140.On function _configure, comment few lines under // Security is king

//      ini_set('session.use_trans_sid', 0);//      ini_set('session.use_strict_mode', 1);//      ini_set('session.use_cookies', 1);//      ini_set('session.use_only_cookies', 1);//      ini_set('session.hash_function', 1);//      ini_set('session.hash_bits_per_character', 4);

Second, go to file index.php on your root project.Put, session_start(); below <?php

Hope this helps.


First, you must make sure that there are no special characters in the session items like '\n' or '\v'. Those characters may lead your string to break in the middle. Try trim() for help.

If that's no use, maybe it's some encoding problem. Try to encrypt the session item before you set it, and decrypt it when you need to use it.


I solved this problem by configuring the $config['cookie_domain'] to localhost

$config['cookie_domain']    = "localhost";

i initially had that variable set to fully qualified domain name such as www.exampledomain.com but meanwhile i was using a local server.

The domain that your script is running under should be the same as the domain set under $config['cookie_domain] to avoid unexpected failure with codeigniter session class.