# Session and how to set login redirect based on role

**URL:** <https://discourse.cakephp.org/t/session-and-how-to-set-login-redirect-based-on-role/7366>\
**Category:** Need Help\
**Created:** [February 28, 2020, 9:23am UTC](https://discourse.cakephp.org/t/session-and-how-to-set-login-redirect-based-on-role/7366 "2020-02-28T09:23:59Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie](https://avatars.discourse-cdn.com/v4/letter/n/dc4da7/32.png) [@newbie](https://discourse.cakephp.org/u/newbie)\
**Post date:** [February 28, 2020, 9:24am UTC](https://discourse.cakephp.org/t/session-and-how-to-set-login-redirect-based-on-role/7366/1 "2020-02-28T09:24:00Z")

</div>

Hello,

1. how do I get the Session to work, I have read the tutorial but I don’t know how to actually get the session to load and start so I can do something like the following when someone logs in.  
Welcome {username}

2. now I have got login working going to the home page once logged in, while working through the CMS tutorial and wondering how I can redirect user based on a role type based on the below code?

In my users table I have a field called role so something like the following?

**Member**

```
    $redirect = $this->request->getQuery('redirect', [
                        'controller' => 'Members',
                        'action' => 'index', 

```

**Partner**

```
 $redirect = $this->request->getQuery('redirect', [
                        'controller' => 'Partners',
                        'action' => 'index',

```

**Super Admin**

```
   $redirect = $this->request->getQuery('redirect', [
                        'controller' => 'Admin',
                        'action' => 'index',
           public function login() {

```

dunno whats happened with post styling tried to wrap the code  
Thanks in advance
