I am new to CI and would normally try to pass some information back to a login page like the following...
public function authenticate()
{
$this->load->model('User_model', '', true);
if ($this->User_model->authenticate($this->input->post('username'), $this->input->post('password')))
{
$this->session->set_userdata('loggedin', true);
header('Location: /');
}
else
{
header('Location: /sessions/login/error?='.'1');
}
}
And then on the login page use a _GET.
So how would I best go about this in CodeIgniter?
From my understanding you want to pass
_GET
variables for the error codes, right? as i see you are using_POST
variables for the form as you should.As you are working with Codeigniter, you can use the URI structure of the framework and instead of working with
_GET
work with the MVC structure.So, instead of redirecting this:
Redirect like this:
Then in your controller for the login, in the error method:
If you still need to work with
_GET
variables, that is possible as well. go to the main application config file of the framework/aplication/config/config.php
and have a look on theEnable Query Strings
section