Jump to content

Library in another library


Ninjakreborn

Recommended Posts

I have a display class I have started using in Codeignitor to do all of my display stuff. I just threw it in Libraries and started using it as one of the built in Codeignitor libraries (by following their naming conventions.

 

For the first time I have tried to use another library inside my display class and it throws an error that it's not a class.

I am simply trying to call the $this->session->flashdata() inside the display class.

 

Is there another way to do this, or am I doing it wrong?

Link to comment
https://forums.phpfreaks.com/topic/202448-library-in-another-library/
Share on other sites

  • 2 weeks later...

As thorpe has said, it needs to be defined.

 

As far as I'm aware, there are 2 options in code igniter.

 

1.) If you need to use the session library throughout your application then check to ensure that it is autoloaded in application/config/autoload.php. It should be on line 42.

// Option 1
$autoload['libraries'] = array('session', 'database');

 

2.) If you only need it for say, a backend then place the line below in the constructor of your backend controller.

// Option 2
$this->load->library('session');

 

Bootnote: I have just noted that you are using your own library. this page advises that you will need to use get_instance() to use the native CI resources.

$CI =& get_instance();

$CI->load->library('session');

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.