동일한 컨트롤러 내의 다른 기능에 대한 액세스 권한이없는 경우 컨트롤러 인덱스로 리디렉션하려고합니다. 내 코딩에 따르면 그것은 무한 루프처럼 보입니다. 제발 저를 도와주세요.codeigniter에서 유효성 검사가 실패한 경우 특정 컨트롤러 기능으로 리디렉션
class Customer_Dashboard extends CI_Controller {
public function __construct() {
$method= $this->router->fetch_method();
if ($this->session->userdata("cus_sel_comp")) {
}else{
if($method !="index"){
redirect(base_url()."customer_dashboard");exit;
}
}
}
public function index() {
// Here do some operations and let the user to select company and update the "cus_sel_comp" session variable. After set that session user can access the other controller functions.
}
public function other_function1() {
}
public function other_function2() {
}
}
위와 동일합니다. 같은 컨트롤러를 사용하여이 작업을 수행해야합니다. 문제는 그 세션이 무한 루프로 설정되어 있지 않다는 것입니다.
저에게 해답을 줄 수 있습니까? –
@GayanFernando가 리디렉션과 관련하여 질문에 답변 해 주셨습니다. 당신은 그것 또는'base_url' 하나를위한 해결책을 묻고 있습니까? –
customer_dashboard 컨트롤러 색인 기능으로 리디렉션해야합니다. 사이트 메인 컨트롤러가 아닙니다. 그렇게 할 수 있습니까? 아니면 리디렉션을 사용하는 것 이외의 다른 방법을 사용할 수 있습니까? –