# How to get last login ip in a rule or hook (not current login info)?

**URL:** <https://community.auth0.com/t/how-to-get-last-login-ip-in-a-rule-or-hook-not-current-login-info/7983>\
**Category:** Get Help\
**Tags:** rules, hooks\
**Created:** [August 27, 2017, 7:26am UTC](https://community.auth0.com/t/how-to-get-last-login-ip-in-a-rule-or-hook-not-current-login-info/7983 "2017-08-27T07:26:50Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![brad2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brad2/32/8925_2.png) [@brad2](https://community.auth0.com/u/brad2)\
**Post date:** [August 27, 2017, 7:26am UTC](https://community.auth0.com/t/how-to-get-last-login-ip-in-a-rule-or-hook-not-current-login-info/7983/1 "2017-08-27T07:26:50Z")

</div>

I am trying to do something in a rule after a used has logged in based on the last time they logged in prior to the current login. Is there a way to do this with the existing rule/hook stuff?

thanks

---

<div class="post-metadata">

**Author:** ![brad2](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/brad2/32/8925_2.png) [@brad2](https://community.auth0.com/u/brad2)\
**Post date:** [August 28, 2017, 6:23am UTC](https://community.auth0.com/t/how-to-get-last-login-ip-in-a-rule-or-hook-not-current-login-info/7983/2 "2017-08-28T06:23:13Z")

</div>

Answering my own question. It looks like you have access to an auth0 object in the rule that already has needed access to updating metadata, so you could store the ip in it during the rule, and then check it at the beginning of the rule for the last login ip…

[https://auth0.com/docs/rules/current/metadata-in-rules#updating-app\_metadata](https://auth0.com/docs/rules/current/metadata-in-rules#updating-app_metadata)

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/how-to-get-last-login-ip-in-a-rule-or-hook-not-current-login-info/7983/3 "2018-03-02T05:56:09Z")

</div>


