• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using class in model

#1
Hey guys,

I have a weird problem and i can't figure out how to solve it...

I have a custom library User.php with de following code:
PHP Code:
defined('BASEPATH') OR exit('No direct script access allowed');

class 
User
{
 
   public $session_prefix 'usrs_';

 
   public $cookie_prefix 'usrc_';

 
   public function __construct()
 
   {
 
       $this->load->model('users_model');

 
       $this->users_model->login_remembered_user();
 
   }

 
   public function __get($var)
 
   {
 
       return get_instance()->$var;
 
   }
 
   
    public 
function is_logged_in()
 
   {
 
       return true;
 
   }


And the model Users_model.php with the following code:
PHP Code:
defined('BASEPATH') OR exit('No direct script access allowed');

class 
Users_model extends CI_Model
{
    public function 
__construct()
    {
        
parent::__construct();
    }

    public function 
login_remembered_user()
    {
        
$cookie_id $this->user->cookie_prefix 'id';
        
$cookie_rc $this->user->cookie_prefix 'rc';

        if(
$this->user->is_logged_in() && get_cookie($cookie_id) && get_cookie($cookie_rc))
        {
            
        }
    }


The problem is that in the model at method login_remembered_user i get the error that class user isn't set, although the user library is autoloaded...

What i'm doing wrong?
Reply


Messages In This Thread
Using class in model - by -V1cu- - 04-21-2017, 03:19 AM
RE: Using class in model - by neuron - 04-21-2017, 03:34 AM
RE: Using class in model - by -V1cu- - 04-21-2017, 03:37 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.