同じコントローラ内の他の機能へのアクセスが許可されていない場合、コントローラインデックスにリダイレクトしようとしています。私のコーディングによると、無限ループのように見えています。私にそれを手伝ってください。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コントローラインデックス関数にリダイレクトする必要があります。サイトメインコントローラ用ではありません。それは可能ですか?それ以外に、リダイレクト以外の方法がありますか? –