# Perspective Shared Script Session Props

**URL:** <https://forum.inductiveautomation.com/t/perspective-shared-script-session-props/50957>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 14, 2021, 2:45pm UTC](https://forum.inductiveautomation.com/t/perspective-shared-script-session-props/50957 "2021-09-14T14:45:30Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicholas](https://avatars.discourse-cdn.com/v4/letter/n/4da419/32.png) [@nicholas](https://forum.inductiveautomation.com/u/nicholas)\
**Post date:** [September 14, 2021, 2:45pm UTC](https://forum.inductiveautomation.com/t/perspective-shared-script-session-props/50957/1 "2021-09-14T14:45:30Z")

</div>

Hello Everyone,

I am attempting to get some information about the perspective session from a shared script. Is there a way to access the session props from the system scripts library? I have tried `system.perspective.getSessionInfo`, but it gives a list of all the sessions. I tried using `system.security.getUsername` to lookup the correct session, but that function is not in the perspective scope. (I am also interested in the gateway address, but `system.util.getGatewayAddress` is also not in perspective scope for some reason.) I know I can pass the session object from a component scope, but that would require a lot of refactoring. Is that really the only way?

---

<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:** [September 14, 2021, 2:51pm UTC](https://forum.inductiveautomation.com/t/perspective-shared-script-session-props/50957/2 "2021-09-14T14:51:10Z")

</div>

To get information about a specific session which is invoking the project script, you’ll need to pass the session into the script as an argument. I know you’re trying to avoid the refactor, but if you want that info then you need to pass something which has that info.

```auto
def my_proj_func(session):
    system.util.getLogger('SessionIPLogger').info(session.props.host)

```

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 14, 2021, 3:05pm UTC](https://forum.inductiveautomation.com/t/perspective-shared-script-session-props/50957/3 "2021-09-14T15:05:02Z")

</div>

Passing the session object is the only _supported_ way. There _is_ a gross hack you can do, but as mentioned in the thread, don't expect support or be surprised if it breaks suddenly on upgrade.

> [@Referencing a session prop from a script library?](https://forum.inductiveautomation.com/t/referencing-a-session-prop-from-a-script-library/33314/5):
>
> In theory, the InternalSession.SESSION [ThreadLocal](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/ThreadLocal.html) would be populated if you’re running a project script from a Perspective thread; so something like this might work: from com.inductiveautomation.perspective.gateway.session import InternalSession session = InternalSession.SESSION.get() if session is not None: system.perspective.print(session.custom.something)

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [September 14, 2021, 3:15pm UTC](https://forum.inductiveautomation.com/t/perspective-shared-script-session-props/50957/4 "2021-09-14T15:15:10Z")

</div>

Always fun to see myself in a link about unsupported or non recommended techniques (:

---

<div class="post-metadata">

**Author:** ![nicholas](https://avatars.discourse-cdn.com/v4/letter/n/4da419/32.png) [@nicholas](https://forum.inductiveautomation.com/u/nicholas)\
**Post date:** [September 14, 2021, 3:23pm UTC](https://forum.inductiveautomation.com/t/perspective-shared-script-session-props/50957/5 "2021-09-14T15:23:13Z")

</div>

This is promising, however it seems that it has broken already. I’m running 8.1.8 and getting this error when attempting that solution: `com.inductiveautomation.ignition.common.script.JythonExecException: ImportError: No module named perspective`  
`

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [September 14, 2021, 3:35pm UTC](https://forum.inductiveautomation.com/t/perspective-shared-script-session-props/50957/6 "2021-09-14T15:35:12Z")

</div>

I would only expect it to work if invoked from a Perspective calling context, but even then it’s possible that classloader restrictions on the gateway are such it won’t work anyways.
