codeIgniter中的重定向错误 [英] Redirect error in codeIgniter

查看:230
本文介绍了codeIgniter中的重定向错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想尝试代码

function validate(){
        $this->load->library('session');
        $this->load->model('inventory/inventoryModel');
        $result = $this->inventoryModel->validateUser();
        if($result == 1){
            $data = array(
                'username' => $this->input->post('username'),
                'is_loged_in' => TRUE 
            );
            $this->session->set_userdata($data);
        }
        else{
            $this->index();
            redirect('inventory/validate');
        }
    }

重定向循环
什么是解决方案?

and getting the error in chrome "This web page has a redirect loop" what is solution?

推荐答案

您可能还在索引函数中调用validate函数。也许你需要添加一些逻辑,只有在不在索引中时才运行验证。

You probably call the validate function in your index function as well. Maybe you need to adds some logic to only run validate when not in index.

这篇关于codeIgniter中的重定向错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆