2013-11-14 45 views
0

我正在嘗試在codeigniter中進行登錄過程,因爲我對它很陌生,並且希望熟悉它。然後我想添加安全保護功能,其中如果儀表板使用URL訪問,如果account_id會議沒有設定我會重定向他們登錄:codeigniter在未登錄時重定向

public function index() { 

    if ($this->session->userdata('account_id') === FALSE) { 


     redirect('/'); 
    }  

    return $this->_renderPage(); 
} 

但隨後它給了我這樣的結果 enter image description here

正如你所看到的,它仍然在儀表板中,但它的所有空白頁面並沒有重定向。 我該如何解決這個問題?

在此先感謝您的幫助。

回答

1

你加載了正確的幫手嗎?用$this->load->helper('url');來做。

後,您可以使用重定向這樣的:redirect('/', 'refresh');

The CodeIgniter documentation about url helper


PS:PHP的方式做到這一點是header('Location: http://www.website.com/');

+0

噢..感謝..我忘了。 。 – Aoi

相關問題