Welcome Guest, Not a member yet? Register   Sign In
Autoload model with usage of autoloaded libraries
#3

[eluser]Escee[/eluser]
&uot;[quote author="Derek Allard" date=;1193695204"]Welcome to CI Escee. I hope after this gets resolved for you we see you around a lot more Wink

Can you post some relevant chunks of your model so we can see how you are using the session?[/quote]

Okay, for example, here is the constructor of the 'member' model which checks if a user is already logged in:

Code:
public function Member ( )
        {
            parent::Model ( );
            
            // If the session 'userid' exists get the username
            $userdata = $this -> session -> userdata ( 'userid' );
            if ( $userdata !== false && ctype_digit ( $userdata ) )
            {
                // Query for the username/id
                $this -> db -> select ( 'id, username' );
                $this -> db -> where ( 'id', $userdata );
                $userquery = $this -> db -> get ( 'users' );
                
                if ( $userquery -> num_rows ( ) == 1 )
                {
                    // Save query recieved data
                    $userdata = $userquery -> row ( );
                    $this -> userid = $userdata -> id;
                    $this -> username = $userdata -> username;
                    $this -> loggedin = true;
                }
            }
        }

And here's a bit of code for a new login:

Code:
public function ProcessLogin ( $username, $password )
        {
            // Get some data and check some stuff
            // ...

            // Login is ok
            $this -> username = $userdata -> username;
            $this -> userid = $userdata -> id;
            $this -> session -> set_userdata ( 'userid', $userdata -> id ); // Set de userid session
            $this -> loggedin = true;
            return true;
        }

When I first load the session library and then the member model in a controller, it works. But i'd like to autoload them both (the session library already does). But when I autoload them both, the member won't find/use/load/... the session library..

Hope you understand :-)

So far CodeIgniter rocks, great documentation, helps allot ;-)

Stefan


Messages In This Thread
Autoload model with usage of autoloaded libraries - by El Forum - 10-29-2007, 08:31 AM
Autoload model with usage of autoloaded libraries - by El Forum - 10-29-2007, 11:00 AM
Autoload model with usage of autoloaded libraries - by El Forum - 10-29-2007, 11:25 AM
Autoload model with usage of autoloaded libraries - by El Forum - 10-29-2007, 01:31 PM
Autoload model with usage of autoloaded libraries - by El Forum - 10-29-2007, 03:05 PM
Autoload model with usage of autoloaded libraries - by El Forum - 10-29-2007, 04:04 PM
Autoload model with usage of autoloaded libraries - by El Forum - 10-29-2007, 04:13 PM
Autoload model with usage of autoloaded libraries - by El Forum - 01-03-2008, 05:15 PM



Theme © iAndrew 2016 - Forum software by © MyBB