After ssl implementation in cakephp 3 return $this->redirect() stop working

public function login() {
//$this->viewBuilder()->layout(‘vodadminlogin’);
$this->viewBuilder()->layout(‘home/homelayout’);

    if ($this->request->is('post') || $this->request->query('provider')) {
        $user = $this->Auth->identify();
         if ($user) {
            // User role wise redirect

            if($user['role'] == 'Guest' || $user['role']== 'Creator'){
                $session = $this->request->session();
                $session->write('userdata', $user);
                $this->Auth->setUser($user);

                $url = $session->read('vurl');

                if($user['role'] == 'Guest'):
                    if($url){
                        return $this->redirect(['controller'=>'pages','action'=>'video'.$url]);
                    }else{
                        return $this->redirect(['controller'=>'pages','action'=>'couchhome']);
                    }
                else:
                    return $this->redirect('/users/');
                endif;

            }else{
                $session = $this->request->session();
                $session->write('userdata', $user);
                $this->Auth->setUser($user);
                return $this->redirect($this->Auth->redirectUrl());
            }
        }
        $this->Flash->error(__('Invalid username or password, try again'));
    }
}

when user login as guest he should be redirect according to condition i have written but it is redirecting to that login page only means redirect not working.

any help would be highly appreciate. Thanks

If it is redirecting to the login page your issue could be due to access permissions. The logged in user is not being authenticated correctly.

so in that case what should i do ? please help i am new to cakephp and ssl