# Add more than 1 user on a session

**URL:** <https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [March 30, 2024, 8:48pm UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110 "2024-03-30T20:48:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Eagel007](https://avatars.discourse-cdn.com/v4/letter/e/7bcc69/32.png) [@Eagel007](https://forum.inductiveautomation.com/u/Eagel007)\
**Post date:** [March 30, 2024, 8:48pm UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/1 "2024-03-30T20:48:00Z")

</div>

Hi ,

I have a situation where 2 operators work on a station. While only one can login, there was no way for us to capture the other person's name. I created a button for authentication challenge and in return it would add 2nd operator,s name to session custom property and a flex repeater at the top would appear with his name. And by clicking on his name it will remove him from session custom propety as well. This I was able to capture more than 1 operators working at a station.

The only issue is, if the same 2nd operator logs in to other station. It allows him to aquire a session. However what i need to implement is it logs him out from their previous logged station not affecting the first operator who logged in initially.

I hope this explains the situation I am trying to tackle and happy to take your suggestions.

Thank you.

---

<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:** [April 2, 2024, 10:18am UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/2 "2024-04-02T10:18:37Z")

</div>

You have to create a dataset tag (or something) that stores the active sessions and their operators. That way all sessions can lookup the operators of the other sessions

---

<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:** [April 2, 2024, 10:57am UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/3 "2024-04-02T10:57:40Z")

</div>

Or, perhaps, broadcast every user auth result, both primary user and secondary user, to all other sessions. So the other sessions can kick them out.

---

<div class="post-metadata">

**Author:** ![Eagel007](https://avatars.discourse-cdn.com/v4/letter/e/7bcc69/32.png) [@Eagel007](https://forum.inductiveautomation.com/u/Eagel007)\
**Post date:** [April 2, 2024, 1:22pm UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/4 "2024-04-02T13:22:06Z")

</div>

Can you please explain in more detail of what do you mean by broadcast?

---

<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:** [April 2, 2024, 3:50pm UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/5 "2024-04-02T15:50:11Z")

</div>

Use `system.util.sendMessage()` with scope=S (not `system.perspective.sendMessage()`), which targets session message handlers (defined in the session, not in any component).

---

<div class="post-metadata">

**Author:** ![Eagel007](https://avatars.discourse-cdn.com/v4/letter/e/7bcc69/32.png) [@Eagel007](https://forum.inductiveautomation.com/u/Eagel007)\
**Post date:** [April 2, 2024, 5:30pm UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/6 "2024-04-02T17:30:44Z")

</div>

from pageStartup event? or sessionStartup?

---

<div class="post-metadata">

**Author:** ![Eagel007](https://avatars.discourse-cdn.com/v4/letter/e/7bcc69/32.png) [@Eagel007](https://forum.inductiveautomation.com/u/Eagel007)\
**Post date:** [April 2, 2024, 5:51pm UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/7 "2024-04-02T17:51:25Z")

</div>

I get this .

> Error running session.handleMessage(session, payload): Traceback (most recent call last): File "function:handleMessage", line 10, in handleMessage at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.lambda$operateOnPage$0(AbstractScriptingFunctions.java:64) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnSession(AbstractScriptingFunctions.java:120) at com.inductiveautomation.perspective.gateway.script.AbstractScriptingFunctions.operateOnPage(AbstractScriptingFunctions.java:47) at com.inductiveautomation.perspective.gateway.script.PerspectiveScriptingFunctions.authenticationChallenge(PerspectiveScriptingFunctions.java:418) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: No perspective page attached to this thread.

---

<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:** [April 2, 2024, 6:30pm UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/8 "2024-04-02T18:30:46Z")

</div>

What is your message handler code?

---

<div class="post-metadata">

**Author:** ![Eagel007](https://avatars.discourse-cdn.com/v4/letter/e/7bcc69/32.png) [@Eagel007](https://forum.inductiveautomation.com/u/Eagel007)\
**Post date:** [April 2, 2024, 6:39pm UTC](https://forum.inductiveautomation.com/t/add-more-than-1-user-on-a-session/88110/9 "2024-04-02T18:39:12Z")

</div>

```
logger = system.util.getLogger('Operator Check - Page Startup')
current_username = payload['current_username']
Full_name = payload['Full_name']
session_id = payload['session_id']
Support_Users = session.custom.Support_Users

if session.props.id != session_id and session.props.auth.user.userName == current_username:
	system.perspective.logout(sessionID=session.props.id, message = Full_name + " Your account has been logged out due to log in at other station. Please contact supervisor for concerns.")
	logger.info("User automatic logout : %s , session: %d" % (current_username, session.props.id))

elif Full_name in Support_Users:
	Support_Users.remove(Full_name)
	logger.info("Support_User Kicked out : %s , session: %d" % (current_username, session.props.id))

```
