The code to associate the session data is in the summarized code below:
PHP Code:
class MY_Session_database_driver extends CI_Session_database_driver {
public function write($session_id, $session_data)
{
// If theres an account ID set in the session data...
if (isset($_SESSION['account_id']))
{
// ... Associate the account ID to the session ID
Accounts_model::assoc_session($_SESSION['account_id'], $session_id);
}
return parent::write($session_id, $session_data);
}
}
PHP Code:
class MY_Session extends CI_Session
{
public function sess_regenerate($destroy = FALSE)
{
$current_session = session_id();
parent::sess_regenerate($destroy);
$new_session = session_id();
// Re-associate all old account activity to the new session
Accounts_model::assoc_session(NULL, $current_session, $new_session);
}
}
Which works fine when the session is being created initially, but it looks like when the sess_time_to_update is reached, it throws an error:
Quote:PHP Fatal error: Class 'Accounts_model' not found in /Users/me/PhpstormProjects/project-App/htdocs/application/libraries/Session/drivers/MY_Session_database_driver.php on line 12
So the Accounts model isnt getting loaded before the session is being regenerated. Its probably not best to try and load it before is it? What would you suggest in this case?
My goal is to have the sessions associated to the accounts, which is working fine, and when the session is regenerated, move the account activity data (NOT THe session data, totally different table) that is associated to the old session ID, to the new session ID. Thus when viewing all the activity for a user, they can see everything that happened for the users activity in one list, as opposed to multiple lists under different sessions