# From perspective, how to trigger action when a user login successfully

**URL:** <https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [May 2, 2023, 7:05am UTC](https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131 "2023-05-02T07:05:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [May 2, 2023, 7:05am UTC](https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131/1 "2023-05-02T07:05:00Z")

</div>

I want to execute a script when a user login the perspective session.  
And the script will execute based on his ID.

I tried to execute the script when the following tag value change:

```auto
self.session.props.auth.user.id

```

```auto
def valueChanged(self, previousValue, currentValue, origin, missedEvents):
	user_id = currentValue
	system.perspective.print("userid"+str(user_id))
	........................

```

But I cannot get the printout each time a new user logged in.

How can I get this function working?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 2, 2023, 8:10am UTC](https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131/2 "2023-05-02T08:10:35Z")

</div>

I suppose you could you could use the on startup session event and check the `session.props.auth` properties to build your logic.

What's the end goal ?

---

<div class="post-metadata">

**Author:** ![nideyijuyidong](https://avatars.discourse-cdn.com/v4/letter/n/7cd45c/32.png) [@nideyijuyidong](https://forum.inductiveautomation.com/u/nideyijuyidong)\
**Post date:** [May 2, 2023, 8:32am UTC](https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131/3 "2023-05-02T08:32:39Z")

</div>

Yes, maybe check the userID at Mainview.

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [May 2, 2023, 10:36am UTC](https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131/4 "2023-05-02T10:36:00Z")

</div>

When a new user login, I need to execute a script to assign properties to this new user.

I will have a try of the startup event.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [May 2, 2023, 10:48am UTC](https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131/5 "2023-05-02T10:48:30Z")

</div>

> [@chaoliang](#):
>
> When a new user login, I need to execute a script to assign properties to this new user.

That's not an end goal, that's the means to the end.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [May 2, 2023, 4:57pm UTC](https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131/6 "2023-05-02T16:57:36Z")

</div>

Your script seems to be in the correct place, but I think your expectations are incorrect; that function prints the supplied string to the browser console of the open session. I think you're looking for something more like this:

```auto
system.util.getLogger("USERID_LOGGING").info(user_id)

```

---

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [May 9, 2023, 3:44am UTC](https://forum.inductiveautomation.com/t/from-perspective-how-to-trigger-action-when-a-user-login-successfully/73131/7 "2023-05-09T03:44:27Z")

</div>

I still cannot get the value change of this property to work.

```auto
self.session.props.auth.user.id

```

But I mapped this tag to a custom tag, then it works to trigger action on the value change.
