# Save $this-\>Auth-\>user('id') on DB

**URL:** <https://discourse.cakephp.org/t/save-this-auth-user-id-on-db/9129>\
**Category:** Uncategorized\
**Created:** [March 17, 2021, 1:00am UTC](https://discourse.cakephp.org/t/save-this-auth-user-id-on-db/9129 "2021-03-17T01:00:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![wtamayom](https://avatars.discourse-cdn.com/v4/letter/w/b2d939/32.png) [@wtamayom](https://discourse.cakephp.org/u/wtamayom)\
**Post date:** [March 17, 2021, 1:00am UTC](https://discourse.cakephp.org/t/save-this-auth-user-id-on-db/9129/1 "2021-03-17T01:00:15Z")

</div>

Hi.  
How can I store the user id in my DB?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [March 17, 2021, 1:58am UTC](https://discourse.cakephp.org/t/save-this-auth-user-id-on-db/9129/2 "2021-03-17T01:58:58Z")

</div>

You’ll need to be much more explicit about what you’re trying to accomplish. Where in the database does it need to go, for example?

---

<div class="post-metadata">

**Author:** ![wtamayom](https://avatars.discourse-cdn.com/v4/letter/w/b2d939/32.png) [@wtamayom](https://discourse.cakephp.org/u/wtamayom)\
**Post date:** [March 17, 2021, 12:41pm UTC](https://discourse.cakephp.org/t/save-this-auth-user-id-on-db/9129/3 "2021-03-17T12:41:08Z")

</div>

Hi.  
I want to store the user\_id in any controller at add and edit actions, so I created the field in every table.  
In older versions I did this way:  
$this-\>request-\>data[‘xxxxr’][‘created\_by’] = $this-\>Auth-\>user(‘id’);  
But i 4X is not possible this way.  
Thanks.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [March 17, 2021, 5:28pm UTC](https://discourse.cakephp.org/t/save-this-auth-user-id-on-db/9129/4 "2021-03-17T17:28:32Z")

</div>

[GitHub - UseMuffin/Footprint: CakePHP plugin to allow passing currently logged in user to model layer.](https://github.com/UseMuffin/Footprint) does exactly this.
