Is this good login process in CodeIgniter? I'm creating my first login process in CodeIgniter. I'm using the simpleloginsecure library for actual session management but I wrote the controller and model myself and I was hoping if you could see any flaws in it.

My User_model Class

&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

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

    function login($email, $password) {
        if($this-&gt;simpleloginsecure-&gt;login($email, $password)) {
            return true;
        }
        return false;
    }
} 

?&gt;


My User Controller class

&lt;?php if(!defined('BASEPATH')) exit('No Direct script access allowed');

Class User extends CI_Controller {

    public function __construct() {
        parent::__construct();
        $this-&gt;load-&gt;model('user_model');
    }

    public function index() {
        if($this-&gt;session-&gt;userdata('logged_in')) {
            redirect('/user/dashboard/', 'location');
        } else {
            $data['message'] = '&lt;p class="error"&gt;You need to be logged in to view the administration area&lt;/p&gt;';
            $this-&gt;load-&gt;view('user/login', $data);
        }
    }

    public function dashboard() {
        if($this-&gt;session-&gt;userdata('logged_in')) {
            $data['title'] = 'Welcome';
            $this-&gt;load-&gt;view('user/dashboard', $data);
        } else {
            $data['message'] = '&lt;p class="error"&gt;You need to be logged in to view the administration area&lt;/p&gt;';
            redirect('/user/login/', 'location');
        }

    }

    public function login() {

        if($this-&gt;session-&gt;userdata('logged_in')) {
            redirect('/user/dashboard/', 'location');
        }

        $this-&gt;form_validation-&gt;set_rules('email', 'E-mail', 'trim|required|valid_email');
        $this-&gt;form_validation-&gt;set_rules('password', 'Wachtwoord', 'trim|required|min_length[4]|max_length[32]');

        if($this-&gt;form_validation-&gt;run() == FALSE) {
            $this-&gt;index();
        } else {
            if($this-&gt;user_model-&gt;login($this-&gt;input-&gt;post('email'), $this-&gt;input-&gt;post('password'))) {
                redirect('/user/dashboard/', 'location');
            } else {
                $this-&gt;index();
            }
        }
    }

    public function logout() {
        $this-&gt;simpleloginsecure-&gt;logout();
        redirect('/user/login/', 'location');
    }



}
Simply use return $this-&gt;simpleloginsecure-&gt;login($email, $password) in the login method.
redirect('/user/xxx') is enough, since location is the default redirect type.
Since you're doing a redirect(), $data['message']is probably "dead code" here. Use CodeIgniter's Flashdata instead.
&lt;p class="error"&gt; should be handled in the view, the controller only needs to say there's an error. For example: $data['message'] = array('error' =&gt; 'This is my error text');
Trimming passwords is dangerous: what if my password starts with a space? Also, a space will look like a real character in an HTML password form, it makes no sense to trim it.
When the validation fails, redirect to the login form and use flashdata to explain what got wrong.