I need to run a few code on every request, always depending on If the user is logged in or not.
Where do I put this code?
Is there any possibility I can pass the data, This code:
public function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('security');
$this->load->library('tank_auth');
$this->lang->load('tank_auth');
$this->load->model('users_model');
if ($this->tank_auth->is_logged_in())
{
$data = $this->users_model->get_userinfo($this->tank_auth->get_username());
if ($data['exp'] >= $data['max_exp']) {
$new_data = array(
'exp' => $data['exp'] - $data['max_exp'],
'level' => $data['level'] + 1,
);
$this->db->where('id', $data['id']);
$this->db->update('users', $new_data);
echo 'Hello?';
}
}
}
This is MY_Controller, in the Core class.. Can I pass this data further? I guess, regrabbing all data, over again in the real class, feels unneccerary.