# Client Event Script - Timer, Switch User Question

**URL:** <https://forum.inductiveautomation.com/t/client-event-script-timer-switch-user-question/20411>\
**Category:** Ignition\
**Tags:** scripting\
**Created:** [October 26, 2018, 9:43pm UTC](https://forum.inductiveautomation.com/t/client-event-script-timer-switch-user-question/20411 "2018-10-26T21:43:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [October 26, 2018, 9:43pm UTC](https://forum.inductiveautomation.com/t/client-event-script-timer-switch-user-question/20411/1 "2018-10-26T21:43:19Z")

</div>

I have a simple script to switch users to a default username and password after a set amount of time.  
See script below.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/8/804ac9aac762f980e91531d8e3bc2f4ba5ff1245.png)

This is working great with one exception. If the client stays inactive the script keeps firing and firing…  
How can I write this so it will only be active if the default user (In this case brewers) is Not logged in?

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 26, 2018, 9:44pm UTC](https://forum.inductiveautomation.com/t/client-event-script-timer-switch-user-question/20411/2 "2018-10-26T21:44:32Z")

</div>

Just read the client tag for username and check for it?  
[System]Client/User/Username

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [October 26, 2018, 9:46pm UTC](https://forum.inductiveautomation.com/t/client-event-script-timer-switch-user-question/20411/3 "2018-10-26T21:46:43Z")

</div>

I’m a complete rookie at this.  
One of my attempts was to do just that but my syntax must have been way off.  
Would you please show me an example.  
Thank you

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [October 26, 2018, 9:49pm UTC](https://forum.inductiveautomation.com/t/client-event-script-timer-switch-user-question/20411/4 "2018-10-26T21:49:32Z")

</div>

```auto
username = "brewers"
password="Mashbrew47"
if system.util.getInactivitySeconds() > 30 and system.tag.read("[System]Client/User/Username").value<>"brewers":
	system.security.switchUser(username,password)

```

---

<div class="post-metadata">

**Author:** ![paulm1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paulm1/32/5900_2.png) [@paulm1](https://forum.inductiveautomation.com/u/paulm1)\
**Post date:** [October 26, 2018, 9:52pm UTC](https://forum.inductiveautomation.com/t/client-event-script-timer-switch-user-question/20411/5 "2018-10-26T21:52:47Z")

</div>

Oh Yeah, I was way off.  
This is working perfectly.  
Thank you
