# Session not always loading correctly

**URL:** <https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [August 1, 2024, 1:26pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038 "2024-08-01T13:26:59Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [August 1, 2024, 1:26pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/1 "2024-08-01T13:26:59Z")

</div>

I am working on an application that uses the Perspective session heavily. I have inputs and labels that bind to session variables and sometime when loading a page I see the default values until I reload the page in which the session values are then loaded.

Has anyone else experienced this?

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [August 1, 2024, 2:12pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/2 "2024-08-01T14:12:37Z")

</div>

Where did you place the code to change/update the session values from their default to the new values you expect?

---

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [August 1, 2024, 2:35pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/3 "2024-08-01T14:35:44Z")

</div>

Uses in scripts. Here is a video of the issue I have censored company information with the red bars. I am navigating to a different screen and then back again. The cancel button is just calling `system.perspective.navigate()`

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [August 1, 2024, 2:48pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/4 "2024-08-01T14:48:32Z")

</div>

Thanks for the video, this helps tremendously. I think maybe you have some code on the onStartup or onPageStartup when you get to this main page...then when you navigate to add a defect and click cancel, the system.perspective.navigate() isn't going to call the onStartup or onPageStartup event again. Instead, your view should have parameters or custom properties that have binding to get the data you need to load the page. However, a full refresh (by swiping down) does reload the page and trigger the onStartup or onPageStartup. Again, one possibility...I can't see how you have your page set up in the designer.

---

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [August 1, 2024, 3:13pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/5 "2024-08-01T15:13:04Z")

</div>

Here is a screenshot of how one of those list items value is configured

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/a/0a769407923e89e41f1572560fcd16372fc35f7e.png)

I do have a startup script but it only sends an authCheck message to the AppBar and set the title in the AppBar

```python
def runAction(self):
	system.perspective.sendMessage('authCheck')
	
	self.session.custom.mobile.title = self.session.custom.mobile.selectedSort.sort_number

```

and here is what the list item component/view looks like

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/c/4/c4989570ffad26f7f69f76f3699e12ce8fdf0700.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/2/720623bb08f08668eb48acf01d9d64befd50d4cd.png)

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [August 1, 2024, 4:16pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/6 "2024-08-01T16:16:31Z")

</div>

Strange. Looks ok so far. Can you show what code you have on the Cancel button? You said system.perspective.navigate(), but are you trying to call back a view or page? try calling back the page and see if the items bind again. Worst case, you could force a re-bind.

---

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [August 1, 2024, 5:18pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/7 "2024-08-01T17:18:38Z")

</div>

The cancel button sends a cancelPartID message that is captured by the root view. I would like to emphasize that the way I have everything setup does work but only sometimes

```python
def onMessageReceived(self, payload):
	system.perspective.navigate('/mobile/container-details')

```

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/8/e8799d023b08a7bec8741789857a53aeed3e792b.png)

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [August 2, 2024, 2:04pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/8 "2024-08-02T14:04:57Z")

</div>

Can you try using `system.perspective.navigateBack()` on the Cancel button to see if the issue is related to the .navigate() function. Maybe it is a bug that is hard to pinpoint because, as you said, it doesn't happen all the time.

---

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [August 7, 2024, 6:57pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/9 "2024-08-07T18:57:04Z")

</div>

I have changed that single navigate to navigateBack and I will see what happens but there are other places where I need to use navigate()

---

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [August 8, 2024, 2:33pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/10 "2024-08-08T14:33:36Z")

</div>

I've seen 5 times just this morning when testing where moving forward in the apps flow I saw the same default values instead of the session data

---

<div class="post-metadata">

**Author:** ![drojas](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drojas/32/3403_2.png) [@drojas](https://forum.inductiveautomation.com/u/drojas)\
**Post date:** [August 12, 2024, 2:29pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/11 "2024-08-12T14:29:51Z")

</div>

Did you solve the issue? If so, how?

---

<div class="post-metadata">

**Author:** ![Chad\_Gregory](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chad_gregory/32/51192_2.png) [@Chad\_Gregory](https://forum.inductiveautomation.com/u/Chad_Gregory)\
**Post date:** [August 29, 2024, 12:04pm UTC](https://forum.inductiveautomation.com/t/session-not-always-loading-correctly/94038/12 "2024-08-29T12:04:11Z")

</div>

Yea.... kinda....

I set my binding to an expression

```python
now()

```

then added a transform script to return the session data that the bind was originally binding to.

At most it shows the default values for a second then populates the correct data
