How to save session data to database just before session get auto destroyed because of timeout?
I am capturing session data when User logout, ex: ip_address, id_user, id_app, save them to database, its working fine when user get logout manually (By calling logout method) but I am not able to capture it when user's session gets auto destroyed after timeout.
Please help me to resolve this problem, I am using Codeigniter 4.1.9
I have try extending the Session library:
Code:
<?php
namespace App\Libraries;
use CodeIgniter\Session\Handlers\FileHandler;
use App\Libraries\Sac_Lib;
class MY_Session extends FileHandler
{
public function gc($max_lifetime)
{
$sacLib = new \App\Libraries\Sac_Lib();
$sacLib->writelogapl_ver3('logout',session()->get('id_app'),session()->get('id_user'),$_SERVER['REMOTE_ADDR']);
parent::gc($max_lifetime);
}
}
?>
But it not working, because I didn't get record in my database when User's session gets auto destroyed after timeout.