Shared Session: work with Python and XOE together
Python and the Xplain Object Explorer (XOE) can share the same analytics session. Changes made via a Python script are reflected in XOE immediately, and vice versa. This page explains how to connect Python to a running XOE session using the Xplain session ID.
Session ID concept
There is a single Xplain session ID: a 32-character hex string that
identifies the analytics session on the server. Both
XplainSession.from_session_id() and xp.load_from_session_id() accept
exactly this same value — they are not different IDs.
How to obtain the session ID:
In Python:
xp.get_session_id()In XOE: enable Developer Mode in Settings, then go to Settings → Session
In the browser: Developer Tools → Application → Cookies →
JSESSIONID
Two ways to use it:
Method |
When to use |
|---|---|
|
Attach to an existing session without re-authenticating (no username/password required). |
|
Load a specific session state after authenticating with your own
credentials via |
Scenario 1: XOE is running — Python joins the session
Use this when XOE is already open in your browser and you want Python to work on the same session without creating a new login.
Step 1 — Copy the session ID
Either of these gives the same value:
XOE: enable Developer Mode in Settings, then go to Settings → Session
Browser: Developer Tools → Application → Cookies →
JSESSIONID
Session ID / JSESSIONID: A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6
Step 2 — Connect Python using the session ID
from xplain import XplainSession
xp = XplainSession.from_session_id(
url="http://myhost:8080",
session_id="A1B2C3D4E5F6G7H8I9J0K1L2M3N4O5P6"
)
Python attaches to the existing session without re-authenticating — no username or password needed.
Step 3 — Verify and continue working
# Confirm which analytics session is active
print(xp.get_session_id())
# Continue analysis — changes appear in XOE immediately
xp.explore.structure()
Scenario 2: Python has started the session — XOE joins
Use this when Python created the session first and you want to visualise or interact with it in XOE.
Step 1 — Start the session in Python and retrieve its ID
from xplain import create_session
xp = create_session()
xp.startup("DemoStartUp")
print(xp.get_session_id())
# A674FF134333C72CE2ICE1782B8006C
Scenario 3: get the Xplain session ID from XOE — Python joins by ID
Use this when XOE is already running and you want Python to load the same analytics session state using its own independent login (no browser cookie needed):
Step 1 — Enable Developer Mode in XOE and copy the Session ID
In XOE Settings, enable Developer Mode:
After enabling, refresh XOE (Ctrl+R / Cmd+R / F5). Go to Settings → Session and copy the Session ID:
Step 2 — Load the session in Python
from xplain import create_session
xp = create_session()
xp.load_from_session_id("A674FF134333C72CE2ICE1782B8006C")
Note
load_from_session_id() requires a full credential-based login first.
If you want to skip re-authentication, use XplainSession.from_session_id()
(Scenario 1) instead — it attaches directly without username or password.