Welcome Guest, Not a member yet? Register   Sign In
Problem with constructor when checking $this->session->userdata()
#1

[eluser]condoace[/eluser]
I have a controller which I would like to keep private entirely. I have created a condition in the controllers constructor to check if a session exists and then do a redirect. It works fine when there is no session (i.e. does the redirect), but if a session exists it comes up with this error, - also see code:

ERROR

Fatal error: Can't use method return value in write context in C:\Users\ME\xampp\htdocs\ggk\application\models\model_empl.php on line 9

CONTROLLER

Code:
function __construct(){
  
  parent :: __construct();
  
  if(!$this->session->userdata('user_id'))
    {
    
     redirect('/login/index/');
    
    }
  
}




Theme © iAndrew 2016 - Forum software by © MyBB