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

#1
[eluser]Unknown[/eluser]
I'm using a custom 404 page:

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

errors class:
Code:
class Errors extends CI_Controller {

public function page_not_found() {

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

}

}

In my template I use this to check the user is logged (the session class is autoloaded):
Code:
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:

Code:
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?


Messages In This Thread
Using $this->library_name-> in 404 error page cause error - by El Forum - 09-25-2011, 01:37 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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