[Solved] Codeigniter session expires frequently

I was working in a Codeigniter project and when I hit refresh button (F5) continuously, My application session was expiring frequently. I googled for a while and found the simple solution.

A solution is to increase the amount of time for the session_time_to_update in codeigniter config.

Since I won’t be updating session frequently. I am setting it to much higher values such as 86400 (24 hours).

Here is my settings

$config['sess_cookie_name']	= 'app_session';
$config['sess_expiration']	= 0;
$config['sess_expire_on_close']	= FALSE;
$config['sess_encrypt_cookie']	= FALSE;
$config['sess_use_database']	= TRUE;
$config['sess_table_name']	= 'app_sessions';
$config['sess_match_ip']	= FALSE;
$config['sess_match_useragent']	= TRUE;
$config['sess_time_to_update']	= 86400; // 24 hours

Since then I haven’t got this problem.

Reference : http://ellislab.com/forums/viewthread/182755/#864970

Samundra Shrestha

I work as fullstack developer. Having spent more than 5 years in the web development technologies, I aspire to create an environment where we can share, learn and grow together.

3 thoughts on “[Solved] Codeigniter session expires frequently

Leave a Reply

Your email address will not be published. Required fields are marked *