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

**URL:** <https://discourse.cakephp.org/t/after-ssl-implementation-in-cakephp-3-return-this-redirect-stop-working/2486>\
**Category:** Need Help\
**Created:** [April 27, 2017, 7:28am UTC](https://discourse.cakephp.org/t/after-ssl-implementation-in-cakephp-3-return-this-redirect-stop-working/2486 "2017-04-27T07:28:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![letrocks](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@letrocks](https://discourse.cakephp.org/u/letrocks)\
**Post date:** [April 27, 2017, 7:28am UTC](https://discourse.cakephp.org/t/after-ssl-implementation-in-cakephp-3-return-this-redirect-stop-working/2486/1 "2017-04-27T07:28:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![akkaweb](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/akkaweb/32/53_2.png) [@akkaweb](https://discourse.cakephp.org/u/akkaweb)\
**Post date:** [April 27, 2017, 3:37pm UTC](https://discourse.cakephp.org/t/after-ssl-implementation-in-cakephp-3-return-this-redirect-stop-working/2486/2 "2017-04-27T15:37:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![letrocks](https://avatars.discourse-cdn.com/v4/letter/l/77aa72/32.png) [@letrocks](https://discourse.cakephp.org/u/letrocks)\
**Post date:** [April 28, 2017, 10:45am UTC](https://discourse.cakephp.org/t/after-ssl-implementation-in-cakephp-3-return-this-redirect-stop-working/2486/3 "2017-04-28T10:45:18Z")

</div>

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