# Show current logged in user

**URL:** <https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100>\
**Category:** Ignition\
**Tags:** vision\
**Created:** [February 21, 2024, 1:49pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100 "2024-02-21T13:49:55Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Larry\_Hardesty](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Larry\_Hardesty](https://forum.inductiveautomation.com/u/Larry_Hardesty)\
**Post date:** [February 21, 2024, 1:49pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/1 "2024-02-21T13:49:56Z")

</div>

Two part question

1. I am trying to setup so if an Admin Account is inactive for set time they are logged out and an Operator Account is logged in.
2. How can we show the current user logged in?

Thanks

---

<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:** [February 21, 2024, 1:58pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/2 "2024-02-21T13:58:08Z")

</div>

In Vision, this sort of information is available in the `[System]` tag provider. Combine that with a client timer event that monitors the inactivity time.

---

<div class="post-metadata">

**Author:** ![valentin.guichard](https://avatars.discourse-cdn.com/v4/letter/v/2bfe46/32.png) [@valentin.guichard](https://forum.inductiveautomation.com/u/valentin.guichard)\
**Post date:** [February 21, 2024, 2:00pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/3 "2024-02-21T14:00:39Z")

</div>

Hi Larry,  
You have the Inactivity timeout properties in the Project properties in the designer.

- For vision it's in Project Properties \> Vision \> Timing  

- For perspective it's in Project Properties \> Perspective \> Inactivity  

To show the current user logged in:

- For Vision you got this in System tag provider.
- For Perspective you got this in the sessions properties

Regards,

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 21, 2024, 2:15pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/4 "2024-02-21T14:15:11Z")

</div>

> [@valentin.guichard](#):
>
> For vision it's in Project Properties \> Vision \> Timing

That is incorrect. Use a Client Timer script to switch away from an admin user.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/d/bd3ae5dffbc377ddd497e0769409ed8013331108.png)

---

<div class="post-metadata">

**Author:** ![Larry\_Hardesty](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Larry\_Hardesty](https://forum.inductiveautomation.com/u/Larry_Hardesty)\
**Post date:** [February 21, 2024, 7:23pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/5 "2024-02-21T19:23:19Z")

</div>

Jordan,

I'm assuming you replace (username, password) with actual user and password? I've tried this several times with no luck. Thanks.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 21, 2024, 7:25pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/6 "2024-02-21T19:25:31Z")

</div>

> [@Larry\_Hardesty](#):
>
> I'm assuming you replace (username, password) with actual user and password?

That is correct.

Did you try this in a running client? It won't work in the designer.

---

<div class="post-metadata">

**Author:** ![Larry\_Hardesty](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Larry\_Hardesty](https://forum.inductiveautomation.com/u/Larry_Hardesty)\
**Post date:** [February 21, 2024, 7:31pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/7 "2024-02-21T19:31:23Z")

</div>

Yessir. I set the script up in Client Event Scripts-Timers, Apply/OK and save. Run the Client and no luck. I have even tried shutting the client down and restarting to see if it needed that for the script to run. I appreciate the help.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 21, 2024, 7:58pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/8 "2024-02-21T19:58:49Z")

</div>

Can you show your work, as my teachers would say?

---

<div class="post-metadata">

**Author:** ![Larry\_Hardesty](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Larry\_Hardesty](https://forum.inductiveautomation.com/u/Larry_Hardesty)\
**Post date:** [February 21, 2024, 8:09pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/9 "2024-02-21T20:09:06Z")

</div>

Sure can. I have tried with and without the getUsername

if system.util.getInactivitySeconds() \> 30 and system.security.getUsername() != Admin:  
system.security.switchUser(Operator, operator)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [February 21, 2024, 8:35pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/10 "2024-02-21T20:35:50Z")

</div>

The username and passwords need to be in quotes.

> **[system.security.switchUser | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-security/system-security-switchUser)**
>
> Attempts to switch the current user on the fly.

Also, when posting code, plese pate it, highlight it, then use the `</>` button to format it. I can't tell if there is an indent on the second line or not.

---

<div class="post-metadata">

**Author:** ![leonardo.godoi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/leonardo.godoi/32/27178_2.png) [@leonardo.godoi](https://forum.inductiveautomation.com/u/leonardo.godoi)\
**Post date:** [February 21, 2024, 8:37pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/11 "2024-02-21T20:37:08Z")

</div>

Can you edit your post so the code is in the preformatted style?  
Like this:  
 ![opera_QqsmLlUzDG](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/1/f152c3d3309ec4c35978665532d23fefa5710e54.gif)  
Just to be sure, on this part

> [@Larry\_Hardesty](#):
>
> and system.security.getUsername() != Admin:

And this part:

> [@Larry\_Hardesty](#):
>
> system.security.switchUser(Operator, operator)

**Admin** and **Operator,operator** are string variables that were defined earlier and you didn't show it in the snippet of code, right?  
Otherwise i don't see anything obviously wrong

---

<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:** [February 21, 2024, 8:38pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/12 "2024-02-21T20:38:17Z")

</div>

You also need to check that the user is not already `Operator`, or the timer will try to switch user over and over and over.

---

<div class="post-metadata">

**Author:** ![Larry\_Hardesty](https://avatars.discourse-cdn.com/v4/letter/l/e9c0ed/32.png) [@Larry\_Hardesty](https://forum.inductiveautomation.com/u/Larry_Hardesty)\
**Post date:** [February 21, 2024, 8:44pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/13 "2024-02-21T20:44:47Z")

</div>

That was the ticket. Thanks again.

---

<div class="post-metadata">

**Author:** ![Muhammad\_Sharjeel](https://avatars.discourse-cdn.com/v4/letter/m/d2c977/32.png) [@Muhammad\_Sharjeel](https://forum.inductiveautomation.com/u/Muhammad_Sharjeel)\
**Post date:** [July 29, 2024, 8:04am UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/14 "2024-07-29T08:04:21Z")

</div>

Hey,  
Hope you all are fine, i am stuck in a problem.  
I want to show the current user who is login in a label which is in nav bar so can anyone help me how to do it  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/4/041e92494ad3f2ee4655b70ec4b6f0fc43af33bf.png)

---

<div class="post-metadata">

**Author:** ![ryan.white](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryan.white/32/73193_2.png) [@ryan.white](https://forum.inductiveautomation.com/u/ryan.white)\
**Post date:** [August 1, 2024, 7:21pm UTC](https://forum.inductiveautomation.com/t/show-current-logged-in-user/86100/15 "2024-08-01T19:21:45Z")

</div>

If you are using perspective, `session.props.auth.user` will contain the current user's username and other information. If you are in vision, the `[system]Client/User` folder in the tag browser should contain username, roles and other information you can use.

Bind the label's text value to either the `session.props.auth.user.username` property if you are in perspective or to the `[system]Client/User/Username` tag if you are in vision.
