| 제목 | __construct() 함수에서 프로그램 종료 시킬때.. | ||
|---|---|---|---|
| 글쓴이 | 한대승(불의회상) | 작성시각 | 2012/10/25 18:08:41 |
|
|
|||
|
물론 tank auth와 같은 라이브러리를 사용 한다면 별 문제 안될거 같긴한데... 모든 로직에서 인증 여부를 판별하기 귀찮아서 Controller의 __construct() 함수에서 확인 후 처리를 하곤 하는데... 평소엔 redirect()로 처리 했습니다. 이번에 종료 하면서 뷰를 뿌려줘야 하는 경우가 있어 아래처럼 했더니
function __construct()
{
parent::__construct();
$this->load->model('auth_model');
if(!$this->auth_model->is_login()) {
$this->load->view('common/login_msg');
exit();
}
}
뷰가 출력이 안되더군요.이럴때 아래 처럼 하시면 됩니다.
function __construct()
{
parent::__construct();
$this->load->model('auth_model');
if(!$this->auth_model->is_login()) {
$this->load->view('common/login_msg');
$this->output->_display(); // 종료전 뷰를 출력한다.
exit();
}
}
|
|||
| 다음글 | PHP Native Session을 기반으로 한 Ses... (3) | ||
| 이전글 | CI 한국어 번역파일 나머지 채웠습니다. (9) | ||
| 없음 |