MVC login authentication

Browser login authentication analysis

During a visit to the background Home (background all functions), you should first determine whether the current browser logged in, do realize the function! If not logged in, go to the login page.

How to determine whether the current browser user login?

Legal administrator -> logged in

Login logo:

  A data.

  How to store this information?

  [Unreasonable] test:

    variable:

            分配(back/AdminController->checkAction())

          if($m_admin->check($admin_name,$admin_pass)){

            $is_login = 'yes';

            $this->_jump('index.php?p=back&c=Manage&a=index');

          }else{

            $ This -> _ jump ( 'index.php p = back & c = Admin & a = login?', 'Administrator illegal information');

          }

  Verify (back / ManageController-> indexAction ())

    public function indexAction(){

      if(!isset($is_login)){

        $this->_jump('index.php?p=back&c=Admin&a=login');

      }

    }

Summary: No, because:

Life cycle issues data for PHP, all data (variables, constants) of the maximum life cycle, a cycle script (the browser makes a request to the server, the server processing the request referred PHP, PHP finished processing to the server, The server responds to the browser, a script that period)

Visible: storage registration flag needs to be a form of cross-script period for storing data (mechanism for persistent storage of data)

[Unreasonable] test:

file:

No, the reason is:

On the server side management of files (database) is not case-browser, any browser are common!

Visible: Log storage flag, you need to be distinguished browser, and multiple requests within the browser cycle can be permanently stored in a data storage mechanism!

More storage mechanism, the session is technology!

 

Session to complete the login status of storage

distribution:

         Back/AdminController->checkAction();

    if($m_admin->check($admin_name,$admin_pass)){

      session_start();

      session[is_login] = 'yes';

      $this->_jump('index.php?p=back&c=Manage&a=index');

    }else{

      $ This -> _ jump ( 'index.php p = back & c = Admin & a = login?', 'Administrator illegal information');

    }

Judge:

         Back/ManageController->indexAction()

    public function indexAction(){

      session_start();

      if(!isset(session[is_login])){

        $this->_jump('index.php?p=back&c=Admin&a=login');

      }

    }

Guess you like

Origin www.cnblogs.com/zsyzsyzsyzsyzsy/p/10983180.html