# Login is success but session was not created

**URL:** <https://discourse.cakephp.org/t/login-is-success-but-session-was-not-created/8280>\
**Category:** Need Help\
**Created:** [August 25, 2020, 10:50am UTC](https://discourse.cakephp.org/t/login-is-success-but-session-was-not-created/8280 "2020-08-25T10:50:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![amitraky](https://avatars.discourse-cdn.com/v4/letter/a/9fc29f/32.png) [@amitraky](https://discourse.cakephp.org/u/amitraky)\
**Post date:** [August 25, 2020, 10:50am UTC](https://discourse.cakephp.org/t/login-is-success-but-session-was-not-created/8280/1 "2020-08-25T10:50:30Z")

</div>

Dear Friends,

I am not able to login due to the session problem in CakePHP 4.

the session is not created so how can fix it.

i have change already ,

‘Session’ =\> [

```
    'defaults' => 'database', //php and database

],

```

 ![image](https://canada1.discourse-cdn.com/flex029/uploads/cakephp/original/2X/a/a856d15ef39a7ef1ac877c8d370bea20cc0ba2c8.png)

$this-\>Auth-\>setUser($user);// this is not working on production  
return $this-\>redirect([‘action’ =\> ‘dataCollections’]);

---

<div class="post-metadata">

**Author:** ![anon81960487](https://avatars.discourse-cdn.com/v4/letter/a/958977/32.png) [@anon81960487](https://discourse.cakephp.org/u/anon81960487)\
**Post date:** [August 26, 2020, 4:09am UTC](https://discourse.cakephp.org/t/login-is-success-but-session-was-not-created/8280/2 "2020-08-26T04:09:44Z")

</div>

Hello,

In CakePHP 4, `$this->Auth->setUser($user);` looks to be deprecated. Looking at one of my CakePHP 4 projects, it looks like `$this->Authentication->setIdentity($user);` is the new version of that code.

Hope that helps!
