Extended user login verification for Codeigniter. You need to modify My_Controller.php and the logon authentication module User. php of the controller. the code is as follows: login {publicfunction _ construct needs to modify My_Controller.php and the logon authentication module User. php of the controller. the code is as follows:
My_Controller.php
Class MY_Controller extends CI_Controller {public function _ construct () {parent ::__ construct ();/* determine whether to log on and whether 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 to after login */redirect ('auth/Login? Redirect = '. $ redirect );}}}
User. php
Class User extends MY_Controller {function login () {if ($ this-> tank_auth-> is_logged_in () {// logged in redirect ('/');} else {// other codes here ...... /* determine whether redirect information exists */$ 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, Note that the form address for submitting the form:
Note the following in login_form:
Using My_Controller.php class MY_Controller extends CI_Controller {public function _ construct...