# Username Tag to Hold Current Session User

**URL:** <https://forum.inductiveautomation.com/t/username-tag-to-hold-current-session-user/90892>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [May 24, 2024, 5:42pm UTC](https://forum.inductiveautomation.com/t/username-tag-to-hold-current-session-user/90892 "2024-05-24T17:42:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 24, 2024, 5:42pm UTC](https://forum.inductiveautomation.com/t/username-tag-to-hold-current-session-user/90892/1 "2024-05-24T17:42:44Z")

</div>

What is the best strategy to document the current user of a perspective session in a tag? I will use the tag in a transaction group.

I've experimented with a runScript() expression inside the UDT with this

```python
[x['username'] for x in system.perspective.getSessionInfo(projectFilter = project) if(address == x['clientAddress'] ) ]

```

It seems to run around 30ms, which I believe Phil would object to using with `runScript()`

Next, would be the same as above, but put in a timer script looping through all sessions of the particular project and `system.tag.writeBlocking()`.

A change script on the userName `auth` prop doesn't seem to work, neither does startup and shutdown events.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [May 24, 2024, 5:44pm UTC](https://forum.inductiveautomation.com/t/username-tag-to-hold-current-session-user/90892/2 "2024-05-24T17:44:33Z")

</div>

Why in a tag? What happens if two users open the application?

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 24, 2024, 5:47pm UTC](https://forum.inductiveautomation.com/t/username-tag-to-hold-current-session-user/90892/3 "2024-05-24T17:47:11Z")

</div>

> [@Transistor](#):
>
> Why in a tag?

> [@dkhayes117](#):
>
> I will use the tag in a transaction group.

> [@Transistor](#):
>
> What happens if two users open the application?

It filters on the address. The project **will** be open on multiple clients in kiosk mode where each client has it's own UDT where one of the tags is the client username.

---

<div class="post-metadata">

**Author:** ![dkhayes117](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/dkhayes117/32/68344_2.png) [@dkhayes117](https://forum.inductiveautomation.com/u/dkhayes117)\
**Post date:** [May 24, 2024, 6:45pm UTC](https://forum.inductiveautomation.com/t/username-tag-to-hold-current-session-user/90892/4 "2024-05-24T18:45:53Z")

</div>

The other way is to create a custom prop on a **view** bound to `auth.userName` with a change script that writes to the UDT tag.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [May 24, 2024, 6:49pm UTC](https://forum.inductiveautomation.com/t/username-tag-to-hold-current-session-user/90892/5 "2024-05-24T18:49:05Z")

</div>

Move your runScript to a project library and call it from a timer event every ten/twenty/thirty seconds. Write the result to a memory tag.

Definitely doesn't belong in an expression tag.

If you have multiple places where this information is needed, do all of them in the same loop.
