Welcome Guest, Not a member yet? Register   Sign In
Problem with constructor in library
#3

[eluser]CIfan1000[/eluser]
Hi,

I am sorry but I don't quite understand - I am fairly new to constructors.

The manual doesn't seem to explain constructors within a custom library and I have searched the forum and not found anything that helps me.

I currently have the lines:
Code:
$CI =& get_instance();
                $CI->load->library('session');

In my function check_if_logged_in() and this works fine.

However, I would like to have multiple functions in this library and so I would like to load the session library in a constructor so it is available for all functions in the library.

I took the
Code:
parent::Controller();
line out of the constructor and put in the session libary load lines into the constructor:

Code:
// Create constructor to load CI libaries and helpers:
        function Myauth()
        {
                $CI =& get_instance();
                $CI->load->library('session');
        }

This also gives me errors - sorry that I don't understand your instructions.

Am I mistaken thinking that I can use a constructor in a library?

Am I mistaken thinking I can load the session library in the constructor and have it available for all functions in the library?

Or do I need to load the session library in each function?


Thanks!


Messages In This Thread
Problem with constructor in library - by El Forum - 11-16-2008, 09:20 AM
Problem with constructor in library - by El Forum - 11-16-2008, 09:30 AM
Problem with constructor in library - by El Forum - 11-16-2008, 09:44 AM
Problem with constructor in library - by El Forum - 11-16-2008, 03:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB