Welcome Guest, Not a member yet? Register   Sign In
HMVC | Undefined property: $session | $this->session is null
#1

[eluser]oukarai[/eluser]
hi

i got this erro message:

A PHP Error was encountered
Severity: Notice
Message: Undefined property: Login::$session
Filename: controllers/login.php

and my login control is

login.php

class Login extends CI_Controller
{
function is_logged_in()
{
$is_logged_in = $this->session->userdata('is_logged_in'); //<=here

if(!isset($is_logged_in) || $is_logged_in != true) {

echo 'You don\'t have permission to access this page.';

die();
}
}
}

and my site control is

class Site extends CI_Controller
{
function __construct()
{
parent::__construct();

modules::run('login/is_logged_in');
}

function members_area()
{
$this->load->view('logged_in_area');
}
}

while its only one part of the source

i access http://localhost/hmvcExample/index.php/s...mbers_area

the error message is showed

i haved autoload libraries session

help!!!
#2

[eluser]InsiteFX[/eluser]
Did you load the Session Class in autoload.php or your controller?

Also next time please use code tags to wrap your code!

InsiteFX
#3

[eluser]oukarai[/eluser]
@InsiteFX


i did autoload the Session Class


$autoload['libraries'] = array('database', 'session');
#4

[eluser]InsiteFX[/eluser]
And where are you setting the session variable?

InsiteFX
#5

[eluser]oukarai[/eluser]
in my login.php's validate_credentials action
Code:
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();
            
        }
    }
#6

[eluser]oukarai[/eluser]
by the way

im studying the hmvc right now according

HMVC: an Introduction and Application

the source all come from the site above
#7

[eluser]InsiteFX[/eluser]
And where is this validate_credentials method located?

InsiteFX
#8

[eluser]oukarai[/eluser]
when i put in the url http://localhost/hmvcExample/index.php/login/
the login form is showed and i put in my id and pass then put the login button

the validate_credentials method is located
#9

[eluser]InsiteFX[/eluser]
Did you download the newest HMVC from the CodeIgniter WIKI?

That Example is for the older CodeIgniter v1.7.3

CodeIgniter 2.0.+ uses PHP 5+ so you need the new HMVC for it to work.

InsiteFX
#10

[eluser]oukarai[/eluser]
yes i did

That Example is for the older CodeIgniter v1.7.3
but i didnt find the codeigniter-modular-extensions-hmvc 5.2

so i go to Modular Extensions - HMVC

the site above and got the most newest hmvc file

by the way , i use ci 2.0.1 now and php 5.3




Theme © iAndrew 2016 - Forum software by © MyBB