Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter 3.0 and flexi auth login problem
#1

After Successfully login when redirect home page it create new blank session alter trough the current session update by flexi auth succesfully.

Here Is my Code:

Code:
[u][b]config.php [/b][/u]
[php]
$config['base_url'] = 'http://localhost/CodeIgniter-3.0.0/';

$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
[/php]

[u][b]routes.php[/b][/u]
[php]
$route['default_controller'] = 'home';
[/php]

[u][b]Home.php (Home conteroller)[/b][/u]
[php]
class Home extends CI_Controller {

    function __construct()
    {
        parent::__construct();
        
        $this->load->library('session');
        $this->auth = new stdClass;
        $this->load->library('flexi_auth');

        
        // Load 'standard' flexi auth library by default.
        //$this->load->library('form_validation');
    }
public function index() {
        $data = array();
        
        if ($this->flexi_auth->is_logged_in()) {
            //echo $this->flexi_auth->get_user_id();
            echo "true";
        } else {
            echo "false";
        }
        
        $data['main_content'] = 'home';
        $data['page_title'] = 'Home';
        $this->load->view('templates/template', $data);
    }
}
[/php]

[u][b]Account.php (Home conteroller)[/b][/u]
[php]

class Account extends CI_Controller {
public function index() {
if (isset($_POST['login'])) {
                
                $validation_rules = array(
                    array('field' => 'email', 'label' => 'Email Address', 'rules' => 'trim|required|valid_email'),
                    array('field' => 'password', 'label' => 'Password', 'rules' => 'trim|required|min_length[4]'),
                );
                $this->form_validation->set_rules($validation_rules);
                // Run the validation.
                if ($this->form_validation->run() == FALSE) {
                    $data['main_content'] = 'account/account';
                    $data['page_title'] = 'Login';
                    $this->load->view('templates/template', $data);
                } else {
                    $identity = NULL; $password =NULL;
                    $identity = $_POST['email'];
                    $password = $_POST['password'];
                    $remember_user = FALSE;
                    
                    if(isset($_POST['remember_user']) && !empty($_POST['remember_user']))
                    {
                        $remember_user = TRUE;
                    }    
                    
                    if($this->flexi_auth->login($identity, $password, $remember_user))
                    {  redirect(base_url());             }
                    
                }
$data['main_content'] = 'account/account';
        $data['page_title'] = 'Login';
        $data['output_data'] = $output_data;
        $this->load->view('templates/template', $data);

}
}
[php]
Reply




Theme © iAndrew 2016 - Forum software by © MyBB