# Logins\_count is undefined

**URL:** <https://community.auth0.com/t/logins-count-is-undefined/133171>\
**Category:** Get Help\
**Tags:** adaptive-mfa, mfa\
**Created:** [May 1, 2024, 5:10am UTC](https://community.auth0.com/t/logins-count-is-undefined/133171 "2024-05-01T05:10:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ysharat](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ysharat/32/44251_2.png) [@ysharat](https://community.auth0.com/u/ysharat)\
**Post date:** [May 1, 2024, 5:10am UTC](https://community.auth0.com/t/logins-count-is-undefined/133171/1 "2024-05-01T05:10:08Z")

</div>

while am printing logins\_count am getting undefined why is that so i have logged many times but still it shows undefined?what i was trying to do if last login is over 40 days want to trigger MFA.  
const logins\_count= event.stats.logins\_count  
console.log(“logins\_count::;”+logins\_count)

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [May 1, 2024, 9:45pm UTC](https://community.auth0.com/t/logins-count-is-undefined/133171/3 "2024-05-01T21:45:37Z")

</div>

Hi @ysharat,

I have tested this on my end, and I am not experiencing the same issue you mentioned. Instead, the `event.stats.logins_count` returns the user’s login count.

Are you able to check this with the [Real-time Webtask Logs Extension](https://auth0.com/docs/customize/extensions/real-time-webtask-logs) and let me know how it goes?

Thanks,  
Rueben

---

<div class="post-metadata">

**Author:** ![ysharat](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/ysharat/32/44251_2.png) [@ysharat](https://community.auth0.com/u/ysharat)\
**Post date:** [May 1, 2024, 10:04pm UTC](https://community.auth0.com/t/logins-count-is-undefined/133171/5 "2024-05-01T22:04:43Z")

</div>

sorry it was not logins\_count , i was refering the below one, infact I was not able to get last\_login attribute.could you pls try that and see if you able to print it?  
const lastLoginString = event.user.last\_login; // Get last login timestamp as string  
console.log(lastLoginString);  
Getting undefined.

---

<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:** [May 17, 2024, 6:21pm UTC](https://community.auth0.com/t/logins-count-is-undefined/133171/6 "2024-05-17T18:21:15Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

---

<div class="post-metadata">

**Author:** ![rueben.tiow](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/rueben.tiow/32/11646_2.png) [@rueben.tiow](https://community.auth0.com/u/rueben.tiow)\
**Post date:** [May 17, 2024, 6:25pm UTC](https://community.auth0.com/t/logins-count-is-undefined/133171/7 "2024-05-17T18:25:33Z")

</div>

Hi @ysharat,

Thanks for the reply.

Unfortunately, the `last_login` attribute is not a callable attribute in the Post-Login action script.

To get the value in the action script, you must use the Management API to get the user’s `last_login`. See [How can I use the Management API in Actions?](https://community.auth0.com/t/how-can-i-use-the-management-api-in-actions/64947).

Alternatively, you could append this information to the user\_metadata and get it in the action script (`event.user.user_metadata.last_login`).

Thanks,  
Rueben
