Welcome Guest, Not a member yet? Register   Sign In
Can i check userlogin in construct ?
#4

(This post was last modified: 11-28-2014, 11:24 AM by unodepiera.)

(11-27-2014, 03:46 AM)bobykurniawan Wrote:
PHP Code:
class Admin extends CI_Controller {
function 
__construct()
{
 
   parent::__construct();
 
  $aut $this->donaturlib->is_admin();
 
   if(!$aut)
 
   {
$msg="Mohon Maaf anda tidak memiliki akses";
$this->session->set_flashdata('donatur',$msg);
redirect('welcome');
 
   }
 
   $this->link ='login/out';
$this->info ='Logout';
}
function 
index()
{
$data['link']=$this->link;
$data['info']=$this->info;
$data['include']= 'default';
$this->load->view('a_template/main.php',$data); 
}


Up there is my script, i'm trying to check the user login in function __construct. It's working fine, but is it 'in the right way'?


I think the best way is to use hooks, tutorial in spanish(http://uno-de-piera.com/uso-de-hooks-en-codeigniter), regards.
Reply


Messages In This Thread
RE: Can i check userlogin in construct ? - by unodepiera - 11-28-2014, 10:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB