Welcome Guest, Not a member yet? Register   Sign In
non-object and userdata
#11

[eluser]Pascal Kriete[/eluser]
You have to load the library:
Code:
$this->load->library('auth');

EDIT: never mind, you said you autoloaded it - reading isn't my strong point today
#12

[eluser]Kemik[/eluser]
[quote author="inparo" date="1201138685"]You have to load the library:
Code:
$this->load->library('auth');
[/quote]

Code:
$autoload['libraries'] = array('database', 'session', 'auth');

Already done Sad
#13

[eluser]wiredesignz[/eluser]
What he said^^^.
EDIT : n/m
#14

[eluser]Pascal Kriete[/eluser]
You're not running PHP 4 by any chance?
#15

[eluser]Kemik[/eluser]
I'm with resellerzoom UK plans.

Quote:PHP 4 & 5 w/Zend & eAccelerator

cPanel says: PHP version 5.2.3
#16

[eluser]Pascal Kriete[/eluser]
Weird, that should work. Well, it might be worth a try, in PHP 4 you would have to do this:
Code:
class Auth {
    
    function __construct() {
        log_message('debug', 'Authorization class initialized.');
    }

    function logged_in() {
        //Get CI Object
        $CI =& get_instance();
        
        // Checks if the user is logged in.
        if ($CI->session->userdata('user_id')) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}
#17

[eluser]Kemik[/eluser]
The PHP4 version you posted works. However, I'm going to have more than one function in that library. Is there no way I can get this working with the get_instance() in the construct?
#18

[eluser]Pascal Kriete[/eluser]
In theory it really should work. Just for kicks, maybe it has trouble with the __constructor method:
Code:
class Auth {

    var $CI;
    
    function Auth() {
        $this->CI =& get_instance();
        log_message('debug', 'Authorization class initialized.');
    }

    function logged_in() {
        // Checks if the user is logged in.
        if ($this->CI->session->userdata('user_id')) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}
#19

[eluser]Kemik[/eluser]
That worked.

Thanks for all your help inparo.
#20

[eluser]wiredesignz[/eluser]
Much nicerer. Wink

Code:
class Auth {
    
    var $_session;
    
    function Auth() {
        $this->_session = new CI_Session();  // create a new session object
        log_message('debug', 'Authorization class initialized.');
    }

    function logged_in() {
        // Checks if the user is logged in.
        if ($this->_session->userdata('user_id')) {
            return TRUE;
        } else {
            return FALSE;
        }
    }
}




Theme © iAndrew 2016 - Forum software by © MyBB