In my config.php
, the session related config in my config file are as follows;
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 1800; //30 minutes
$config['sess_expire_on_close'] = FALSE;
$config['sess_encrypt_cookie'] = FALSE;
$config['sess_use_database'] = TRUE;
$config['sess_table_name'] = 'rd_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_match_useragent'] = TRUE;
$config['sess_time_to_update'] = 300;
For normal usage of the site the session expires after half an hour of login. However I have a feature in my website where user can play timer based tasks. For example when user clicks a button, the timer is started, he does certain task after some times, when he is done he clicks stop button and the timer is stopped and time is saved in the database.
The problem here is the task might lats more than 30 minutes, so session gets expire when user is playing timer. I can't change the sess expiration time in config because for other users (who is not playing timer) it should timeout after 30 minutes. So as suggested in other thread, when user starts timer, I make an ajax call to change the sess expiration time dynamically. Here is the method, that is called -
public function sessiontimeout($time){
$session_lifetime = $time > 0 ? $time: 864000;
$this->config->set_item('sess_expiration', $session_lifetime);
echo "Session lifetime set to ".$this->config->item("sess_expiration")." seconds";
exit;
}
However this didn't work, user gets logged out in 30 minutes. how can I achieve this when timer is clicked the ajax call is made to extend the existing timeout and when timer is stopped, the session expiration time is reset to 30 minutes.
Thanks