php - How to extend session time out in code igniter? -


in config.php, session related config in config file 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 site session expires after half hour of login. have feature in website user can play timer based tasks. example when user clicks button, timer started, task after times, when done clicks stop button , timer stopped , time saved in database.

the problem here task might lats more 30 minutes, session gets expire when user playing timer. can't change sess expiration time in config because other users (who not playing timer) should timeout after 30 minutes. suggested in other thread, when user starts timer, make ajax call change sess expiration time dynamically. here method, called -

 public function sessiontimeout($time){     $session_lifetime = $time > 0  ? $time: 864000;     $this->config->set_item('sess_expiration', $session_lifetime);     echo "session lifetime set ".$this->config->item("sess_expiration")." seconds";     exit; } 

however didn't work, user gets logged out in 30 minutes. how can achieve when timer clicked ajax call made extend existing timeout , when timer stopped, session expiration time reset 30 minutes.

thanks

hi don't need change config file . run ajax after timeinterval after logged controller function.
means hitting after login url through ajax request. codeigniter auto update current login user session. thats simple


Comments

Popular posts from this blog

PySide and Qt Properties: Connecting signals from Python to QML -

c# - DevExpress.Wpf.Grid.InfiniteGridSizeException was unhandled -

scala - 'wrong top statement declaration' when using slick in IntelliJ -