php-CodeIgniter 3-离子验证“重定向过多”

我正在使用Ion Auth创建登录系统.我有以下代码:

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Main extends CI_Controller {

    function __construct() {

        parent::__construct();
        $this->load->library( array( 'ion_auth' ) );

    }

    public function index()
    {

        $this->load->view( 'templates/main/header' );
        $this->load->view( 'templates/main/navigation' );
        $this->load->view( 'Home' );
        $this->load->view( 'templates/main/footer' );

    } // END: index()

    public function logowanie()
    {

        $data = $this->data['title'] = "Login";

        $this->load->view( 'templates/main/header', $data );
        $this->load->view( 'logowanie' );
        $this->load->view( 'templates/main/footer' );

        if ( isset($_POST) ) {

            $login = $this->input->post( 'username' );
            $password = $this->input->post( 'password' );

            $login_process = $this->ion_auth->login( $login, $password );

            if ( $login_process ) {
                redirect( 'panel' );
            } else {
                redirect( 'main/logowanie' );
            }

        }
    } // END: logowanie()

    public function logout()
    {
        $logout = $this->ion_auth->logout();
        redirect('/', 'refresh');
    }


} // END: class Panel

我收到错误消息:“重定向过多”

为什么?

解决方法:

您可以更改此代码:

  if ( $login_process ) {
             redirect( 'panel' );
         } else {
             redirect( 'main/logowanie' );
         }

通过

  if ( $login_process ) {
             $redirect_var = 'panel';
         } else {
             $redirect_var = 'main/logowanie';
         } redirect($redirect_var);
上一篇:ionic4 标题栏 ion-toolbar 默认 底部会显示一个底边框 解决


下一篇:android内存管理-ION/PMEM【转】