# How to Read Session Custom Variables in a Tag Value Change Script?

**URL:** <https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [August 21, 2025, 8:55am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022 "2025-08-21T08:55:53Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![TechEnlive](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TechEnlive](https://forum.inductiveautomation.com/u/TechEnlive)\
**Post date:** [August 21, 2025, 8:55am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/1 "2025-08-21T08:55:53Z")

</div>

Hi everyone,

I need to access **session custom variable values** within a **Tag Value Changed script**. Is there a way to retrieve all the session custom variables from this script context?

Any suggestions or best practices would be greatly appreciated!

Thanks in advance.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/9/c9907ac2edae2a8f14b8fa1b8acf507c305d8440.png)

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [August 21, 2025, 9:13am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/2 "2025-08-21T09:13:01Z")

</div>

This is not really ever going to work, tag change scripts run on the gateway, session variables are unique to every session on the gateway.

Explain what you are trying to achieve, and we will likely have a way to achieve it.

---

<div class="post-metadata">

**Author:** ![TechEnlive](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TechEnlive](https://forum.inductiveautomation.com/u/TechEnlive)\
**Post date:** [August 21, 2025, 9:19am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/3 "2025-08-21T09:19:11Z")

</div>

**irst, thanks for your reply.**

At the start of the session, we create several custom variables with predefined values. Later, we use these variables to update different tag values as needed.

For example, if the value of **Tag A** changes from 10 to 5, we want to update **Tag B** using the value of a session custom variable (e.g., **V1** ).

I hope this clarifies why we need to access session variables in this context.

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [August 21, 2025, 9:30am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/4 "2025-08-21T09:30:57Z")

</div>

Why do you create them as session variables? Do they change based on each user logged on?  
Are they the same values for every user logged on?

---

<div class="post-metadata">

**Author:** ![TechEnlive](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TechEnlive](https://forum.inductiveautomation.com/u/TechEnlive)\
**Post date:** [August 21, 2025, 10:02am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/5 "2025-08-21T10:02:08Z")

</div>

**Yes, these values are the same for all users.**

We have created them as **global variables** , but as you know, in Perspective we cannot directly create true global variables.

Is there any way to **read these variables within a Tag Value Change script**?

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [August 21, 2025, 10:12am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/6 "2025-08-21T10:12:15Z")

</div>

A global variable in Ignition is a Memory Tag, don’t use these as session variables.  
Make a memory tag and set your tag change script to change the value using writeBlocking().

---

<div class="post-metadata">

**Author:** ![Nathan\_Moore](https://avatars.discourse-cdn.com/v4/letter/n/d78d45/32.png) [@Nathan\_Moore](https://forum.inductiveautomation.com/u/Nathan_Moore)\
**Post date:** [August 21, 2025, 10:17am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/7 "2025-08-21T10:17:48Z")

</div>

This is possible, but a bit dangerous as users are not guaranteed to have the same session parameter value. If you never change these and its the same for every user its probably. safe enough, but there is almost certainly a better way to go about it.

Writting to a memory tag like @David_Stone stated, should work.

---

<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:** [August 21, 2025, 11:38am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/8 "2025-08-21T11:38:09Z")

</div>

> [@TechEnlive](#):
>
> Is there any way

No. That's is why you are being directed to use other techniques.

In Ignition, the type of variable that is persistent and is common to all users is the memory tag.

If you needed something that was per-user, and also needed to react to tag changes, you would bind the tag into a session custom property, and write a property change script there (not on the tag).

---

<div class="post-metadata">

**Author:** ![TechEnlive](https://avatars.discourse-cdn.com/v4/letter/t/3be4f8/32.png) [@TechEnlive](https://forum.inductiveautomation.com/u/TechEnlive)\
**Post date:** [August 21, 2025, 11:53am UTC](https://forum.inductiveautomation.com/t/how-to-read-session-custom-variables-in-a-tag-value-change-script/110022/9 "2025-08-21T11:53:03Z")

</div>

Thanks alot David and Pturmel.
