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
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');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.