【发布时间】:2017-01-25 05:56:55
【问题描述】:
如果未授权访问同一控制器中的其他功能,我将尝试重定向到控制器索引。根据我的编码,它看起来像无限循环。请帮我这样做。
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() {
}
}
我的编码如上。我需要使用相同的控制器来执行此操作。问题是如果该会话未设置,则存在无限循环。
【问题讨论】:
标签: php codeigniter redirect construct