You may have found that CodeIgniter sometimes does not successfully remove sessions from the sessions table in the database. Unused sessions are instead cleared of their user_data field
, but that the row remains in the sessions table.
I have often had to write specific database queries to clear sessions. I usually put these queries in the My_Controller
class(refer to the Extending your controllers recipe in this chapter); however, I have recently begun to use Hooks to perform this. Then it's always working in the background and I don't need to think about it.
We're going to amend the following file:
/path/to/codeigniter/application/config/config.php
Open the /application/config/config.php
file and ensure that the setting for enable_hooks
is TRUE
, as shown in the following code snippet:
$config['enable_hooks'] = TRUE;