# How to reference a session customProp in a gatewayEvents script context

**URL:** <https://forum.inductiveautomation.com/t/how-to-reference-a-session-customprop-in-a-gatewayevents-script-context/61832>\
**Category:** Ignition\
**Tags:** perspective, ignition81, scripting\
**Created:** [July 13, 2022, 8:57am UTC](https://forum.inductiveautomation.com/t/how-to-reference-a-session-customprop-in-a-gatewayevents-script-context/61832 "2022-07-13T08:57:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![cesma2000](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cesma2000](https://forum.inductiveautomation.com/u/cesma2000)\
**Post date:** [July 13, 2022, 8:57am UTC](https://forum.inductiveautomation.com/t/how-to-reference-a-session-customprop-in-a-gatewayevents-script-context/61832/1 "2022-07-13T08:57:02Z")

</div>

Hi folks.

I’ve implemented a script like scripting function (perspective 8.1.18) that run in a gateway Event context, so I do this call in the event tab _MyScriptingFile.myfunc()_.  
In my script, I need to access to a specific sessionCustomProp but for the gateway context if I type  
something like _self.session.custom.obj\_myComponentSettings_ I have an error (and it’s correct  
for the gateway context).

I actually pass this reference like a parameter assigned before calling the script func.

My question is: how (if is it possible) can I insert the reference of this sessionCustomProp inside my scripting function?  
I suppose something like:  
_.session.custom.obj\_myComponentSettings_

THX in advance, C.

---

<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:** [July 13, 2022, 9:09am UTC](https://forum.inductiveautomation.com/t/how-to-reference-a-session-customprop-in-a-gatewayevents-script-context/61832/2 "2022-07-13T09:09:12Z")

</div>

You cannot.

Even if you could, which user’s session would you need?

You **can** send a message with `system.util.sendMessage` to scope `S` and let a session message handler do the work.

---

<div class="post-metadata">

**Author:** ![cesma2000](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cesma2000](https://forum.inductiveautomation.com/u/cesma2000)\
**Post date:** [July 13, 2022, 9:39am UTC](https://forum.inductiveautomation.com/t/how-to-reference-a-session-customprop-in-a-gatewayevents-script-context/61832/3 "2022-07-13T09:39:40Z")

</div>

Hi.

Sorry, but I can’t understand why I need to consider the user of the session?

In any case, this is a good solution but I’d like to remove the assign operation before  
the calling of scripting func and put it inside a scripting function to not have always to remember  
myself to do it before the func call.

Maybe something like [system.util.getSessionInfo] return the reference of the session?

---

<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:** [July 13, 2022, 9:47am UTC](https://forum.inductiveautomation.com/t/how-to-reference-a-session-customprop-in-a-gatewayevents-script-context/61832/4 "2022-07-13T09:47:17Z")

</div>

Gateway events don’t **have** a session. If no client is connected, there’s no session at all.

If what you are trying to do is specific to a session, and the project library function is always going to be called from a session/page/view/component event, then pass the session as a function parameter. Or pass the page/view/component (`self`) if that is more useful.

Project library scripts don’t have a scope of their own. You must pass scope-related variables to them. As function arguments, typically.

---

<div class="post-metadata">

**Author:** ![cesma2000](https://avatars.discourse-cdn.com/v4/letter/c/c6cbf5/32.png) [@cesma2000](https://forum.inductiveautomation.com/u/cesma2000)\
**Post date:** [July 13, 2022, 9:52am UTC](https://forum.inductiveautomation.com/t/how-to-reference-a-session-customprop-in-a-gatewayevents-script-context/61832/5 "2022-07-13T09:52:26Z")

</div>

Thanks for the clarification P., I actually pass variables to my script as function arguments to turn around  
of the scope limits.

C.
