【问题标题】:CodeIgniter 3 - Ion Auth "Too many redirects"CodeIgniter 3 - Ion Auth“重定向太多”
【发布时间】:2015-04-13 00:45:49
【问题描述】:

我正在使用 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

我收到错误:“重定向太多”

为什么?

【问题讨论】:

    标签: php codeigniter authentication ion-auth


    【解决方案1】:

    您可以更改此代码:

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

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

    【讨论】:

    • 当我添加你的代码时,它停止工作每个页面,没有它只有登录页面
    猜你喜欢
    • 2012-11-15
    • 2013-02-11
    • 1970-01-01
    • 1970-01-01
    • 2012-07-07
    • 1970-01-01
    • 2016-08-16
    • 2012-06-23
    • 2011-10-12
    相关资源
    最近更新 更多