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

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.

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() 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.

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 ** @PGriffith ** 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!

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.

Some things are worth fighting for.

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

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

1 Like

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.

2 Likes