# Log out button not working when first starting up project

**URL:** <https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204>\
**Category:** Ignition\
**Created:** [December 16, 2021, 3:48pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204 "2021-12-16T15:48:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 3:48pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/1 "2021-12-16T15:48:18Z")

</div>

After switching between pages 4-5 times it works. But at first it does not do anything. The page icon loads, the tags change because i see my component disappear. But it stays on the same page, like something stops it from switching. right it works after swapping a few times i have no ideas.

here is logout button code.

```auto
system.nav.swapTo('Logged Off')
system.security.switchUser("plc", "plc")
system.tag.writeToTag("[Client]BadgeSystem/DisplayCountdown", 0)
system.tag.writeToTag("[Client]BadgeSystem/TimerRunning", 0)
system.tag.writeToTag("[Client]BadgeSystem/TimerValue", 0)

```

im using 7.8.5

thank you , it is critical i figure this out.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 16, 2021, 3:50pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/2 "2021-12-16T15:50:21Z")

</div>

> [@andrews](#):
>
> thank you , it is critical i figure this out.

Then you should contact support.

From the script you've provided I don't see anything that would cause this not to work.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 3:51pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/3 "2021-12-16T15:51:48Z")

</div>

@lrose my company does not have a support contract which is why I am here.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 3:54pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/4 "2021-12-16T15:54:34Z")

</div>

Idk much about vision, and i doubt it rly matters for this but still. Avoid running code after navigating away. do the nav at the end.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 3:57pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/5 "2021-12-16T15:57:46Z")

</div>

@victordcq I tried moving the swap to the end but still get the same results.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [December 16, 2021, 3:59pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/6 "2021-12-16T15:59:26Z")

</div>

i thought so:/

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 4:00pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/7 "2021-12-16T16:00:18Z")

</div>

@victordcq its just so weird that it works perfectly after a few clicks then the occasional mess up.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 4:00pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/8 "2021-12-16T16:00:41Z")

</div>

I also do not see anything in the diagnostic window

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 4:02pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/9 "2021-12-16T16:02:55Z")

</div>

I get this in my console log

`SQLTagsClientProxy	Removing Tags due to switching user.`

any relation?

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 4:19pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/10 "2021-12-16T16:19:53Z")

</div>

I adjusted the code, and it does not work for the time i.e. page to logout. then i go back to page and logout and it all works. very weird.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [December 16, 2021, 4:24pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/11 "2021-12-16T16:24:57Z")

</div>

Try writing the tags first, then changing the user, then navigating.

Also, not familiar with 7.8, do you have a `system.tag.writeAll()`?

---

<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:** [December 16, 2021, 4:29pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/12 "2021-12-16T16:29:34Z")

</div>

I would do the switch user last, and in a separate function via invokeLater.  
Also consider using a single call to write all the tags synchronously.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 6:13pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/13 "2021-12-16T18:13:59Z")

</div>

@pturmel @lrose I do this is revised code, does not look to be writing to tags.

```auto
tags = ["[Client]BadgeSystem/DisplayCountdown", "[Client]BadgeSystem/TimerRunning", "[Client]BadgeSystem/TimerValue"]
values = [0, 0, 0]
def testwrite(tags, values)):
    system.tag.writeAll(tags,values)
system.util.invokeLater(testwrite)
system.nav.swapTo('Logged Off')
system.security.switchUser("plc", "plc")

```

i also tried

```auto
tags = ["[Client]BadgeSystem/DisplayCountdown", "[Client]BadgeSystem/TimerRunning", "[Client]BadgeSystem/TimerValue"]
values = [0, 0, 0]
def testwrite(tags, values):
	import system
    	system.tag.writeAll(tags,values)
system.util.invokeLater(testwrite)
system.nav.swapTo('Logged Off')
system.security.switchUser("plc", "plc")

```

---

<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:** [December 16, 2021, 6:19pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/14 "2021-12-16T18:19:11Z")

</div>

> [@pturmel](#):
>
> I would do the switch user last, and in a separate function via invokeLater

Do this. And I see typos and wrong indentation.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 6:33pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/15 "2021-12-16T18:33:04Z")

</div>

@pturmel tags writing, still not swapping window though.

```auto
tags = ["[Client]BadgeSystem/DisplayCountdown", "[Client]BadgeSystem/TimerRunning", "[Client]BadgeSystem/TimerValue"]
values = [0, 0, 0]
system.tag.writeAll(tags,values)  
system.nav.swapTo('Logged Off')
def switcharu():
	import system
	system.security.switchUser("plc", "plc")
system.util.invokeLater(switcharu)

```

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 6:37pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/16 "2021-12-16T18:37:07Z")

</div>

first time it does not, but if log back in to window then try to log out again it works.

---

<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:** [December 16, 2021, 6:54pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/17 "2021-12-16T18:54:32Z")

</div>

Try a 1000 millisecond delay on the invokeLater.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 7:06pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/18 "2021-12-16T19:06:08Z")

</div>

@pturmel I added the delay and still not working. I see the loading refresh icon in the upper right corner but it stays on the same page even if i click 10 times. However I can swap between other windows no problem. just not the log out button one, very strange.

I am gonna try something i like dislike and adding the extra code in the other buttons. i’ll post back if it works.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 7:29pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/19 "2021-12-16T19:29:19Z")

</div>

@pturmel @lrose @victordcq  
Thank you for all your help. The original code I posted works! As ugly as it may be.

The issue was the logged off page set to open on startup. Once I turned that off, duplicated that page, changed the name, set duplicated page to open on start up, it works perfectly now.

---

<div class="post-metadata">

**Author:** ![andrews](https://avatars.discourse-cdn.com/v4/letter/a/898d66/32.png) [@andrews](https://forum.inductiveautomation.com/u/andrews)\
**Post date:** [December 16, 2021, 7:32pm UTC](https://forum.inductiveautomation.com/t/log-out-button-not-working-when-first-starting-up-project/54204/20 "2021-12-16T19:32:31Z")

</div>

not sure why the open on startup would cause those issues. maybe a bug?
