# Terminate Dormant Sessions Scripting

**URL:** <https://forum.inductiveautomation.com/t/terminate-dormant-sessions-scripting/40819>\
**Category:** Ignition\
**Created:** [November 19, 2020, 8:04pm UTC](https://forum.inductiveautomation.com/t/terminate-dormant-sessions-scripting/40819 "2020-11-19T20:04:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [November 19, 2020, 8:04pm UTC](https://forum.inductiveautomation.com/t/terminate-dormant-sessions-scripting/40819/1 "2020-11-19T20:04:23Z")

</div>

Is there any way to kill a dormant session through scripting?

I have a client message handler on our project called terminate.  
When you have the client sessionID you can call the message handler using that ID and it will run system.util.exit(1).  
This works great from an HMI where i have all the client IDs from system.util.getSessionInfo() but when the client is in a dormant state this does not work.  
Which it probably doesn’t work because it can’t reach it and get a successful response that the message handler executed successfully.

Now from the gateway you can terminate dormant sessions from the status page -\> vision clients.  
This works great for me when i’m available.  
I need a way to kill this in the gateway via a timer script or tag change script on the gateway side where a user writes a client ID to a tag and the gateway runs a script on that tag using the value as a parameter to terminate that session.

Anyone have any ideas?

---

<div class="post-metadata">

**Author:** ![jramirez3](https://avatars.discourse-cdn.com/v4/letter/j/a183cd/32.png) [@jramirez3](https://forum.inductiveautomation.com/u/jramirez3)\
**Post date:** [July 2, 2021, 12:34pm UTC](https://forum.inductiveautomation.com/t/terminate-dormant-sessions-scripting/40819/2 "2021-07-02T12:34:12Z")

</div>

I was able to figure this out with a Gateway scoped script that can be found here.

[Killing a Dormant Session in an Ignition HMI](http://nextgenscadaprogrammer.com/blog1.html)

---

<div class="post-metadata">

**Author:** ![Miguel\_Cimildoro](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Miguel\_Cimildoro](https://forum.inductiveautomation.com/u/Miguel_Cimildoro)\
**Post date:** [October 31, 2023, 3:02pm UTC](https://forum.inductiveautomation.com/t/terminate-dormant-sessions-scripting/40819/3 "2023-10-31T15:02:02Z")

</div>

hi, I am trying to do something similar... is there any way to close the session of a Client (VISION) by means of a script?

---

<div class="post-metadata">

**Author:** ![Felipe\_CRM](https://avatars.discourse-cdn.com/v4/letter/f/dfb087/32.png) [@Felipe\_CRM](https://forum.inductiveautomation.com/u/Felipe_CRM)\
**Post date:** [October 31, 2023, 3:46pm UTC](https://forum.inductiveautomation.com/t/terminate-dormant-sessions-scripting/40819/4 "2023-10-31T15:46:55Z")

</div>

The original link seems to be dead, but fortunately there seems to be a companion article up on Medium, although it doesn't contain the full script.

> **[Killing a Dormant Session in an Ignition HMI](https://nextgenscadaprogrammer.medium.com/killing-a-dormant-session-in-an-ignition-hmi-804fc44a32a6)**
>
> http://nextgenscadaprogrammer.com/blog1.html

In case this ever goes down as well, I'm going to quote the key paragraph here:

> [@Jacob Ramirez via Medium.com](#):
>
> Basically the script is doing this, we are getting objects created to access gateway related functions ( `sessionManger = SRContext.get().getGatewaySessionManager()` ). Then we need to get all client sessions ( `sessions = sessionManager.findSessions(ApplicationScope.CLIENT)` ). Which returns all the sessions in an ArrayList. Now we can loop through them and find the one that matches because we need the `ClientReqSession ` object and not simply the string text of the `clientID` . When finding the matching `ClientReqSession ` that matches the `clientID ` that was passed into the tag, then we can kill the session. We achieve this by setting the max inactive interval of 0. It does provide a message when its your active session. The line to provide the admin user is actually unnecessary, it works without it.

---

<div class="post-metadata">

**Author:** ![boandersen](https://avatars.discourse-cdn.com/v4/letter/b/13edae/32.png) [@boandersen](https://forum.inductiveautomation.com/u/boandersen)\
**Post date:** [January 14, 2026, 7:42am UTC](https://forum.inductiveautomation.com/t/terminate-dormant-sessions-scripting/40819/5 "2026-01-14T07:42:34Z")

</div>

FYI the medium article is not there anymore
