CodeIgniter Forums

Full Version: Using $this->library_name-> in 404 error page cause error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I'm using a custom 404 page:

$route['404_override'] = 'errors/page_not_found';

errors class:
class Errors extends CI_Controller {

public function page_not_found() {

  $data = array(
   'page' => '404_view',
   'meta_title' => 'Pagina non trovata'
  $this->load->view('template', $data);



In my template I use this to check the user is logged (the session class is autoloaded):
if ($this->session->userdata('logged'))

When I try to access a non-existant function inside a controller (like for example /events/asd) this error appears:

Message:  Undefined property: CI_Loader::$session

when I try to access a non-existant controller (/asd) everything is ok.

The same error appear when I use my custom libraries.

I think the error is caused by the scope of the variable $this, what should I do?