# Help on log out navigation

**URL:** <https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326>\
**Category:** Ignition\
**Created:** [December 11, 2018, 4:27am UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326 "2018-12-11T04:27:47Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 11, 2018, 4:27am UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/1 "2018-12-11T04:27:47Z")

</div>

I don’t know how to do much script. There is a log out icon that logs out user logging in. I would love to some how navigate out of screen while clicking on log out. How is this done. It logs out user, but I don’t know how to do other option.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 11, 2018, 4:55am UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/2 "2018-12-11T04:55:07Z")

</div>

Right-click on the icon in Designer and choose Scripting. You’ll likely find the script there that does the logout. Choose an appropriate [system.nav](https://docs.inductiveautomation.com/display/DOC79/system.nav) function and add it to the script you find there. If you can’t get the desired results, post your script with three triple back quotes on one line above and one line below it and let us know what is happening and what you’d like to happen.

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 11, 2018, 4:57am UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/3 "2018-12-11T04:57:52Z")

</div>

Ok. I really appreciate your reply and will post script tomorrow while at work. I am little old school and was always on factory talk me/se and was faster in doing stuff like this. But I now understand how powerful python language is.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 11, 2018, 5:03am UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/4 "2018-12-11T05:03:36Z")

</div>

You bet; there’s a learning curve with anything new, but Ignition has been one of the most rewarding ones for me. Welcome to the forum!

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 11, 2018, 5:47am UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/5 "2018-12-11T05:47:13Z")

</div>

Got it thanks. I am was not sure what was wrong with me. But I forgot the tab was there to do the navigation, Iol. I was beat at the e d of the day. I just added auto log out script and it worked, but it completely logs the client out. I would like to auto logout and navigate to main menu, should I just paste in what the navigation button do ?

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 11, 2018, 5:59am UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/6 "2018-12-11T05:59:20Z")

</div>

I tried it and it still completely logged off. Here is the script.

`Preformatted text<img src="//cdck-file-uploads-us1.s3.dualstack.us-west-2.amazonaws.com/inductiveautomation/original/2X/3/34160decafb6f7f9ca5791433fa6edf9e651a64c.jpg" width="243" height="500">`

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/34160decafb6f7f9ca5791433fa6edf9e651a64c.jpg)

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 11, 2018, 6:15am UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/7 "2018-12-11T06:15:03Z")

</div>

Yes, you can add to/edit the scripts it creates. However, if you log out and don’t have auto login enabled you’ll just get the login screen, not the Main Window page you’re looking for.

In Designer, go to Project-\>Properties-\>Client Login to setup auto login for a user with access to only what you want accessed before login (at least the Main Window). You’ll need to check Enable Auto-Login and fill in that username and password you want it to switch to on logout to allow access to Main Window.

Then your script will likely work. You may need to put the window change lines before the logout line in the script.

---

<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 11, 2018, 1:31pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/8 "2018-12-11T13:31:01Z")

</div>

Be aware that auto-login does significantly reduce the overall security of your site, and is not recommended by IA for current projects. Yeah, there are reasons we users want to keep it, but it is a security hole.

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 11, 2018, 5:45pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/9 "2018-12-11T17:45:11Z")

</div>

I tried this script and it works, but now it keeps running it. I did not use logout in the script because even if i set the auto log in with user name and password it still logged me out. If I use log out in script in stead of using switch user, it only runs once.

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/f/ff4b4afc7837fccf2380fdf787dc5aebf20a006e.PNG)

---

<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 11, 2018, 6:19pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/10 "2018-12-11T18:19:44Z")

</div>

Try indenting your last two lines so they are part of the “if” statement.

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 11, 2018, 8:40pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/11 "2018-12-11T20:40:07Z")

</div>

It stills does the same. Any other options ?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 11, 2018, 8:43pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/12 "2018-12-11T20:43:52Z")

</div>

Your script in screen clipping above will run any time there is no activity (mouse movement, etc.) for ten seconds when the script runs. If you want it to wait for a longer period of inactivity, change the “10” in it to the number of seconds of inactivity you want to require to execute the lines indented below the if.

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 12, 2018, 4:59pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/13 "2018-12-12T16:59:45Z")

</div>

It still does the same thing. My issue is, if they are logged in and are in a security screen and logged out, they remain in that screen.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 12, 2018, 5:10pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/14 "2018-12-12T17:10:25Z")

</div>

Based on your use of `system.util.getInactivitySeconds()` I assumed this script was running somewhere other than on a logout button. If this is on your logout button, your script while never run because the inactivity seconds will always be zero when it runs (due to the fact the button was just pressed, which counts as activity). If this is on a button, you probably want your script to run any time the button is pressed. Remove the if condition like this:

```auto
window = system.nav.openWindow('Main Window')
system.nav.centerWindow(window)
system.security.switchUser('view', 'view')

```

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 12, 2018, 5:18pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/15 "2018-12-12T17:18:28Z")

</div>

it was set in the auto log out, under client script.  
Here is what I am trying to do. I am little old school and used to Factory talk ME/SE and this makes it easier.  
I have visual buttons that navigate to screens when I sign on to do maintenance. When those buttons appear, I can go to the other screens. What I need is a auto log out to this generic profile, system.security.switchUser(‘view’, ‘view’) and window changed back to main window, window = system.nav.openWindow(‘Main Window’) so they are not left in a security screen. I am pretty sure this can be done, but this SCADA system relies alot on script which is the part I need help on.

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e6b9d51419fce728134fe18c547a2431645397f6.png)

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 12, 2018, 5:28pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/16 "2018-12-12T17:28:37Z")

</div>

I would put this in Client Timer Scripts with a delay of maybe 5000 ms (however often you want it to check inactivity):

```auto
# Switch to Main Window and view user when inactive.
if system.util.getInactivitySeconds() > 10:
	system.nav.swapTo('Main Window')
	system.security.switchUser('view', 'view')

```

I’m taking a guess here that `swapTo` is likely what you want; you can change that back to `openWindow` if not.

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 12, 2018, 5:41pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/17 "2018-12-12T17:41:45Z")

</div>

what about this ?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [December 12, 2018, 5:47pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/18 "2018-12-12T17:47:41Z")

</div>

Those timer script settings look good; it should run 1000 ms after the last time it finished.

Is something still not working? If so, please copy your script, press Ctrl-Shift-C in the post box here on the forum and then Ctrl-Shift-V to paste your code in the preformatted text block to make it easy to read

---

<div class="post-metadata">

**Author:** ![alex.cordova.ee](https://avatars.discourse-cdn.com/v4/letter/a/f1d935/32.png) [@alex.cordova.ee](https://forum.inductiveautomation.com/u/alex.cordova.ee)\
**Post date:** [December 12, 2018, 6:05pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/19 "2018-12-12T18:05:02Z")

</div>

it worked, but I should have stated I don’t want it to work all the time. so what happens is when I am on the main window the screen glitches of and on, because script always runs. Also operators still want to look at the screen they are operating but will lose control options which is ok, they can log back on. So is their any way to some how add some thing in the script that only excutes when certain people log in. For example something thing like this

IF user view looged on  
THEN dont run script  
IF user 1,2,3,4 logged in  
THEN swich window to main window  
log user out.

# Switch to Main Window and view user when inactive.

if system.util.getInactivitySeconds() \> 100:  
system.nav.swapTo(‘Main Window’)  
system.security.switchUser(‘view’, ‘view’)

---

<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:** [December 12, 2018, 6:05pm UTC](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326/20 "2018-12-12T18:05:42Z")

</div>

I have a similar application where a supervisor needs to log in to adjust setups. This will switch screens if it is in the setup screen, otherwise, it just switches the user.

```python
# Check for inactivity for a non-user account
if system.util.getInactivitySeconds() > 300 and system.security.getUsername() != "defaultUser":
	# Check if setup screen is showing
	if system.nav.getCurrentWindow() == "Main Windows/Setup":
		# Swap to main screen
 		system.nav.swapTo("Main Windows/Main")
		# switch to default user
		system.security.switchUser("defaultUser","superSecretPassword")
	else:
		# Otherwise, just switch to the default user
		system.security.switchUser("defaultUser","superSecretPassword")

```

Looking at it now, it could be shortened up a bit, but this should provide enough clarity to show what it’s doing.

[Next page](https://forum.inductiveautomation.com/t/help-on-log-out-navigation/21326.md?page=2)
