# Accessing Custom Session Property Names and Values Through Script

**URL:** <https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 2, 2025, 5:55pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162 "2025-10-02T17:55:48Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Slick](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Slick](https://forum.inductiveautomation.com/u/Slick)\
**Post date:** [October 2, 2025, 5:55pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162/1 "2025-10-02T17:55:48Z")

</div>

Hello,

I would like to access custom session property names and their corresponding values in a script so that I can save them to a database table. Is there a function in Ignition that will return an object/dataset containing the custom session properties and the corresponding values? If not, how can I access custom session property names and values in a script?

I’d like to access an object or something similar that looks like this:

{Custom Session Property 1: Value of Custom Session Property 1, … Custom Session Property n: Value of Custom Session Property n}

Thanks.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 2, 2025, 6:02pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162/2 "2025-10-02T18:02:55Z")

</div>

You've mentioned 'session' so I'm assuming Perspective. (There are optional tags below your title. I'll add it in.)

Any view or component on the view can access the session props. To get the object it would just be something like,  
`myProps = self.session.custom.myCustomProps`  
and you can find this using the Browse Properties button on the script editor.

To save to a database you'll need to decide the column format. For a string column, for example, you'd need to convert the JSON to a string.

Let us know which flavour of database you're using.

---

<div class="post-metadata">

**Author:** ![Slick](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Slick](https://forum.inductiveautomation.com/u/Slick)\
**Post date:** [October 2, 2025, 6:16pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162/3 "2025-10-02T18:16:51Z")

</div>

Got it, thank you for the information. Is it also possible to do something like `myProps = self.session.custom.myCustomProps` in a project or gateway script? Can I get custom session properties outside of views and view components.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 2, 2025, 6:18pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162/4 "2025-10-02T18:18:08Z")

</div>

I wouldn't think so, other than to pass them as a parameter from the view calling the gateway script.

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 2, 2025, 6:21pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162/5 "2025-10-02T18:21:58Z")

</div>

> [@Slick](#):
>
> Can I get custom session properties outside of views and view components.

You have to access the session properties from a session scope. That is not to say that you can't have project library scripts which are intended to work with session properties, but you have to send the 'self' object to the function.

Note: Project library scripts run in the scope that they are called from, they do not have any defined scope.

---

<div class="post-metadata">

**Author:** ![Slick](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Slick](https://forum.inductiveautomation.com/u/Slick)\
**Post date:** [October 2, 2025, 6:29pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162/6 "2025-10-02T18:29:49Z")

</div>

> [@lrose](#):
>
> Note: Project library scripts run in the scope that they are called from, they do not have any defined scope.

This makes sense and I think is where my confusion was stemming from. Is this also true for gateway scripts? Can you pass the session object to them?

Thanks,

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [October 2, 2025, 6:33pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162/7 "2025-10-02T18:33:08Z")

</div>

If by gateway scripts, you mean Gateway Event Scripts, then other than message handlers, there isn't really a way to send the session object to them. You'll need to be more specific with what you're trying to accomplish to get a better answer.

---

<div class="post-metadata">

**Author:** ![Slick](https://avatars.discourse-cdn.com/v4/letter/s/53a042/32.png) [@Slick](https://forum.inductiveautomation.com/u/Slick)\
**Post date:** [October 3, 2025, 12:20pm UTC](https://forum.inductiveautomation.com/t/accessing-custom-session-property-names-and-values-through-script/111162/8 "2025-10-03T12:20:50Z")

</div>

Yes, I meant gateway event script, so you answered my question. Thank you.
