CodeIgniter processing user login Verification URL jump, mainly related to the my_controller.php page and login Verification Module user.php page, the specific code is as follows:
my_controller.php page:
Copy the Code code as follows: Class My_controller extends Ci_controller
{
Public Function __construct ()
{
Parent::__construct ();
/* Determine whether to log in and determine if the current URL is auth/login*/
if (! $this->tank_auth->is_logged_in ()
&& ($this->router->fetch_class ()! = ' Auth ' && $this->router->fetch_method ()! = ' Login ')
{
$redirect = $this->uri->uri_string ();
if ($_server[' query_string ')
{
$redirect. = '? '. $_server[' query_string '];
}
/* Jump to the user login page and specify the url*/to jump after login
Redirect (' auth/login?redirect= '. $redirect);
}
}
}
user.php page:
Copy the Code code as follows: Class User extends My_controller
{
function Login ()
{
if ($this->tank_auth->is_logged_in ()) {//logged in
Redirect ('/');
} else {
Other codes ...
/* Determine if there is redirect information */
$data [' redirect '] = Isset ($_get[' redirect ')? $_get[' redirect ': '/';
if ($this->form_validation->run ()) {//validation ok
if ($this->tank_auth->login (
$this->form_validation->set_value (' login '),
$this->form_validation->set_value (' Password '),
$this->form_validation->set_value (' Remember '),
$data [' Login_by_username '],
$data [' Login_by_email ']) {//success
Redirect ($data [' redirect ']);
} else {
Error handling
}
}
$this->load->view ("Login_form")
}
}
/*
Note: In Login_form, you need to be aware that the form address is submitted:
*/
}
It is important to note in Login_form that the form address of the submission forms is:
Copy the Code code as follows: