[eluser]cmh24[/eluser]
Hey everybody,
I get an error-message while trying to deploy HMVC (5.4) with CI 2.03. I followed the nettuts-Tutorial, it's a bit outdated, so I made the necessary adjustments. Now I'm halfway through and now I encouter a problem.
By the way here is the link to the tutorial.
net.tutsplus.com/tutorials/php/hvmc-an-introduction-and-application/
The error message says.
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Login::$session
Filename: controllers/login.php
Line Number: 34
and
Fatal error: Call to a member function userdata() on a non-object in C:\xampp\htdocs\hmvc-example\application\modules\login\controllers\login.php on line 34
This is the beginning of my login-controller
Code:
<?php
class Login extends CI_Controller
{
function index()
{
$data['main_content'] = 'login_form';
$this->load->view('includes/template', $data);
}
function validate_credentials()
{
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query) // if the user's credentials validated...
{
$data = array(
'username' => $this->input->post('username'),
'is_logged_in' => true
);
$this->session->set_userdata($data);
redirect('site/members_area');
}
else // incorrect username or password
{
$this->index();
}
}
function is_logged_in()
{
$is_logged_in = $this->session->userdata('is_logged_in');
if(!isset($is_logged_in) || $is_logged_in != true)
{
echo 'You do not have permission to access this page. <a href="../login">Login</a>';
die();
//$this->load->view('login_form');
}
}
This is the part that makes the problem.
Code:
$is_logged_in = $this->session->userdata('is_logged_in');
This is line 34.
It happens when I try to login and enter the members_area. Here is the site-controller.
Code:
<?php
class Site extends CI_Controller
{
function __construct()
{
parent::__construct();
modules::run('login/is_logged_in');
}
function members_area()
{
$this->load->view('logged_in_area');
}
function another_page() // just for sample
{
echo 'good. you are logged in.';
}
}
The session library is autoloaded and a encryption key has been set. So, I am dependent on your help!
Thanks in advance!
Max