php - Ion Auth not redirecting properly during log in


I am using ion auth to create a login system for my codeigniter application. I have created routes for better URLs so that for example;


is now


The "routing rule" i am using to achieve this is

$route['login'] = 'auth/login';

and it is working fine, i.e typing it directly in the browser's address bar takes me to the log in page. The problem occurs when logging in. When i click on the log in button, i get directed back to


where of course i get a "404 page Not Found" error. I cannot figure out which part of ion auth is causing this behavior. I have checked thelogin() method of theauth.phpcontroller and nothing there (as far as i can see) is the culprit.

My routes.php looks like this;

$route['default_controller'] = "pages/view";
$route['404_override'] = '';

$route['login'] = 'auth/login';
$route['register'] = 'auth/create_user';

$route['(:any)'] = 'pages/view/$1';

and thelogin() mehod;

//log the user in
function login()
    $this->data['title'] = "Login";

    //validate form input
    $this->form_validation->set_rules('identity', 'Identity', 'required');
    $this->form_validation->set_rules('password', 'Password', 'required');

    if ($this->form_validation->run() == true)
        //check to see if the user is logging in
        //check for "remember me"
        $remember = (bool) $this->input->post('remember');

        if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
            //if the login is successful
            //redirect them back to the home page
            $this->session->set_flashdata('message', $this->ion_auth->messages());
            redirect('/', 'refresh');
            //if the login was un-successful
            //redirect them back to the login page
            $this->session->set_flashdata('message', $this->ion_auth->errors());
            redirect('auth/login', 'refresh'); //use redirects instead of loading views for compatibility with MY_Controller libraries
        //the user is not logging in so display the login page
        //set the flash data error message if there is one
        $this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');

        $this->data['identity'] = array('name' => 'identity',
            'id' => 'identity',
            'type' => 'text',
            'value' => $this->form_validation->set_value('identity'),
        $this->data['password'] = array('name' => 'password',
            'id' => 'password',
            'type' => 'password',

        $this->_render_page('login', $this->data);

I appreciate any views that may help shed a light on this mystery. Thank you.




You need to openviews/auth/login.php and change

<?php echo form_open("auth/login");?>


<?php echo form_open("login");?>

People are also looking for solutions to the problem: php - how to combine two different queries?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.