• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using $this->library_name-> in 404 error page cause error

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?

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.