# Force a new session ID if user opens more tabs of same project?

**URL:** <https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 22, 2024, 9:51pm UTC](https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220 "2024-02-22T21:51:30Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ironyeti1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ironyeti1/32/36635_2.png) [@ironyeti1](https://forum.inductiveautomation.com/u/ironyeti1)\
**Post date:** [February 22, 2024, 9:51pm UTC](https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220/1 "2024-02-22T21:51:30Z")

</div>

I have a project with a UI view used at a few stations. Each station launches the project and then selects their station ID. We make heavy use of session custom properties.

When using separate devices (iPads in this case) all is fine. But in development and QA testing I'd like to open multiple tabs in my browser, one for each station. But the session ID stays the same (because it's the same project), so the new tab's session props starting overwriting the ones on the prior tab.

I have session event scripts set up, and I can detect when the current session ID is already used (I save the ID in a session custom prop during startup). But I can't see a way to force a different session ID to be used, so that I can keep all the tabs unique. I know keeping sharing the session ID has many advantages, but sometimes I want the isolation.

It's worth noting that I can get different IDs if I use different browsers and Incognito mode, but that's tedious, and limited (1 Chrome, 1 Chrome Incognito, 1 Edge, 1 Edge InPrivate).

As a work-around, I could generate unique groupings of the custom props on each startup. But then _every_ function needs to know that ID in order to call the correct group.

---

<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:** [February 22, 2024, 10:01pm UTC](https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220/2 "2024-02-22T22:01:56Z")

</div>

Use a "private" browser to get the separation. (Whoops, you already noticed that.)

If you need per-page storage within a session, you want my Integration Toolkit module's [pageVarMap()](https://www.automation-pros.com/toolkit/doc/scripting.html#pagevarmap) set of functions. It was created specifically for this use-case.

It is a common dictionary created/provided to all of the main, popup, docked, and nested views in a single browser page. Populated by script, with optional binding updates after scripted changes.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [February 22, 2024, 10:15pm UTC](https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220/3 "2024-02-22T22:15:10Z")

</div>

Unfortunately (for now) the correct answer for this is kind of tricky to use...

Session props are a really convenient place to store properties that you may want multiple views in a hierarchy to access, but the multi-tab or multi-window problem is an annoying one. The ideal answer here is to leverage page props, but they are really tricky to manage at this time (\*\* cough \*\* @paul-griffith \*\* cough \*\*)

A page prop would allow you to achieve this, while also allowing you to leverage the glory of multiple tabs/windows.

It is pretty tricky to affectively leverage page props at the moment, and I can try to explain if desired, but a relatively easier way would be to do something like this:

- Create a session property named `page_props` that contains an object
- On the startup of your relevant view, grab your `page_id` and set a default value of an empty object on your `session.custom.page_props`, then leverage _THAT_ as your custom properties point for individual pages.

Not perfect, but it does do the trick.

EDIT: I haven't tried this but it looks worth a shot if you're able to use third party modules!

> [@pturmel](#):
>
> If you need per-page storage within a session, you want my Integration Toolkit module's [pageVarMap()](https://www.automation-pros.com/toolkit/doc/scripting.html#pagevarmap) set of functions. It was created specifically for this use-case.
> 
> It is a common dictionary created/provided to all of the main, popup, docked, and nested views in a single browser page. Populated by script, with optional binding updates after scripted changes.

---

<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:** [February 22, 2024, 10:19pm UTC](https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220/4 "2024-02-22T22:19:02Z")

</div>

> [@kgamble](#):
>
> to do something like this

The issue with hacking up session props to hold page props by ID is that there's no cleanup. You have to do that yourself, and it can get messy (aka buggy). A java solution based on weak references will clean up as soon as Ignition itself cleans up.

> [@kgamble](#):
>
> able to use third party modules

Some things are worth fighting for.

---

<div class="post-metadata">

**Author:** ![kgamble](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kgamble/32/8019_2.png) [@kgamble](https://forum.inductiveautomation.com/u/kgamble)\
**Post date:** [February 22, 2024, 10:20pm UTC](https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220/5 "2024-02-22T22:20:04Z")

</div>

> [@pturmel](#):
>
> A java solution based on weak references will clean up as soon as Ignition itself cleans up.

100%, unfortunately if you require a native solution though this requires a native way to get object references directly instead of their object wrappers

---

<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:** [February 22, 2024, 10:21pm UTC](https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220/6 "2024-02-22T22:21:33Z")

</div>

> [@kgamble](#):
>
> instead of their object wrappers

I won't say simple, but it wasn't too difficult from within the SDK.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [February 22, 2024, 11:06pm UTC](https://forum.inductiveautomation.com/t/force-a-new-session-id-if-user-opens-more-tabs-of-same-project/86220/7 "2024-02-22T23:06:22Z")

</div>

I'm a bit biased here, but use of Selenium allows for opening multiple browsers quickly with their own unique Session Ids. These would typically be used for automated testing, but there's no reason you can't spin them up and then hijack them for manual testing.
