[eluser]soluicius[/eluser]
Hello,
I followed this tutorial(
https://tutsplus.com/course/codeigniter-best-practices/ - 04-Using Third Party Libraries) but i’m stuck while securing the pages.
I think spark doesn’t load ion_auth model
I get this error:
Code:
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Welcome::$ion_auth
Filename: controllers/welcome.php
Line Number: 9
Fatal error: Call to a member function logged_in() on a non-object in C:\wamp\www\application\controllers\welcome.php on line
Here is my controller:
1) user.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function login()
{
echo 'Login form';
}
}
/* End of file user.php */
/* Location: ./application/controllers/user.php */
2) welcome.php
Code:
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Welcome extends CI_Controller {
public function __construct() {
parent::__construct();
if ($this->ion_auth->logged_in() == false) {
redirect('user/login');
}
}
/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{
$this->load->view('welcome_message');
}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
and in autoload.php i have:
Code:
$autoload['sparks'] = array('ion_auth/2.5.0');
EDIT: Solved