# Perspective Session Id Not Unique

**URL:** <https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712>\
**Category:** Ignition\
**Tags:** perspective, ignition80\
**Created:** [October 15, 2020, 12:45pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712 "2020-10-15T12:45:24Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 15, 2020, 12:45pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/1 "2020-10-15T12:45:24Z")

</div>

Perspective 8.0.16 - Chrome Win10x64

Is the session Id designed to be unique per session? What I see is that it doesn’t change if the session is on the same box. If I open up multiple sessions on the same box they all have the same Id. Is this normal? Typically this isn’t a problem, except when I want to test. Vision didn’t have this issue.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [October 15, 2020, 1:17pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/2 "2020-10-15T13:17:03Z")

</div>

Try opening it in a different browser or in incognito mode.

Session ids are unique per session, but what you’re missing is that just because you opened up a new tab or window in chrome doesn’t mean you are opening a new HTTP session. Open gmail or facebook or anything else you are logged into in another tab - you’re still logged in because it’s the same session.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 15, 2020, 1:46pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/3 "2020-10-15T13:46:20Z")

</div>

If I were to launch a session from the designer multiple times, would this create unique IDs? For me, it does not. To your point, opening up one in edge and one in chrome works for me, not sure why I didn’t think of that. Also Incognito works as well. Thanks.

---

<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:** [October 15, 2020, 4:13pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/4 "2020-10-15T16:13:19Z")

</div>

Suppose you open a session from the Designer by selecting Launch Session (or even launching a page from the Page Configuration panel). We’ll say that the session has an ID of “AAAAAA”. If you attempt to launch a second session, your gateway opens a new page for the existing session because you already have an existing session in the chosen browser. This second tab will have the same “AAAAAA” Session ID.

If you close all tabs and try to immediately launch a new session, you’ll see that the new session still has the same “AAAAAA” session ID because sessions have an inherent time-to-wait before the session is removed from the Gateway registry. This is to prevent sessions from losing state in the event a wifi connection drops, or cellular service disconnects, or you switch networks. This setting can be managed in the Designer, and is available for both desktops and mobile devices as separate values.

![Screen Shot 2020-10-15 at 9.07.05AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/7/371d0abe62768bca6a737e9d6ca37a14f645a358.png)

You can also look at the Gateway to examine the status of current sessions. Examination of the page located at `Status > Connections > Perspective Sessions` will provide a list of all open Perspective sessions. In the event a session is still waiting to timeout, you will still see it as a “live” session here.

To always make sure you are starting a NEW session:

1. You must make sure you have no windows open in the browser you are going to be using.
2. You must then wait for the period of time specified for your session timeout.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [October 15, 2020, 4:29pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/5 "2020-10-15T16:29:27Z")

</div>

Thanks for the great explanation!

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [November 5, 2020, 5:54pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/6 "2020-11-05T17:54:37Z")

</div>

Hi @cmallonee, I know this thread is old-ish, but I have a related question and this thread is similar enough to not open a new post… I understand the session ID now a lot better, thanks to the above posts.

However, I don’t understand how the page ID works. If a look at page properties, there is a field called `pageId`, but it contains a path, not an identifier. When I try to use a function like `system.perspective.sendMessage()` and specify the sessionId and that pageId, I don’t receive the messages. I was able to receive messages if I look up the sessionId and pageId from `system.perspective.getSessionInfo()` and hard code it into my scripting (that is obviously a bad approach; I would like to use those dynamically).

My question: _ **How do I get the pageId of a Perspective view from a binding?** _ I’m using a popup with an inline frame, and I want to pass in the sessionId and pageId into the popup with the iframe so that I can communicate with the rest of the view components, but I can’t get it to work dynamically.

Second question: _ **Does the pageId change from session to session?** _ It makes sense for the session ID to be different for every session, but is the pageId the same id across every session? (Essentially, can I hard-code the pageId into a script and it will reference a specific page?)

_ **EDIT:** _ I opened up many sessions and opened the same page, and my logs showed the same pageID. So I’m leaning towards a pageId being the same across sessions, but that is only based on anecdotal evidence. I would still like to hear the experts.

---

<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:** [November 5, 2020, 7:35pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/7 "2020-11-05T19:35:01Z")

</div>

There are two different contexts to keep in mind when developing Perspective projects: Session and Designer.

The Designer NEVER has any "true" Page. You'll notice that you can't do any navigation within the designer, nor can you open Popups or Docked Views. That being said, the Designer replies on some contexts to properly function, and one of those is we need a "fake" page in order to render any View. This "fake" page is what you're seeing in the Designer. In a session with true Pages you'll actually get a valid ID which is I _believe_ an eight-digit alpha-numeric unique ID for the Page.

> [@YF129701](#):
>
> How do I get the pageId of a Perspective view from a binding?

```auto
# as a binding
page.props.pageId

```

If you're referencing the value in a script, you want to use `self.page.props.pageId` .

> [@YF129701](#):
>
> Does the pageId change from session to session?

Yes, the pageId will change from session to session. You can check this yourself by opening a session in a different browser. So, no - do NOT hard-code Page IDs.

> [@YF129701](#):
>
> I opened up many sessions and opened the same page, and my logs showed the same pageID.

This should not be true. I just tried this and found different pageIds across different sessions. What value were you seeing for `pageId`?

Note: When calling `system.perspective.sendMessage()`, the ID of the current session is used if no `sessionId` is provided, so you don't need to supply the SessionId unless you're trying to contact OTHER sessions.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [November 5, 2020, 8:25pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/8 "2020-11-05T20:25:17Z")

</div>

> [@cmallonee](#):
>
> If you’re referencing the value in a script, you want to use `self.page.props.pageId`

That returns a pageId like **`NativeDocuments/NativeDocumentEditor`** , which if you specify as a parameter in a `system.perspective.*` function that takes a page or session ID, it will not work (in my experience).

The page ID I am looking for (and one that I verified works) is something like **`14f7cf5b`**.

> [@cmallonee](#):
>
> Yes, the pageId will change from session to session. You can check this yourself by opening a session in a different browser. So, no - do NOT hard-code Page IDs.

Yes I see my mistake here (not correctly binding the `pageId`). I do get different `pageId`s from different sessions. See snip (binding a custom property to **`system.perspective.getSessionInfo()`**):

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/2472363d167985166416f0fd38b671217967c245.png)  
The first list element is my Incognito session and the second list element is my regular browser. The third one is my designer, which I filter out in the script. Notice what the `pageId`s look like.

> [@cmallonee](#):
>
> Note: When calling `system.perspective.sendMessage()` , the ID of the current session is used if no `sessionId` is provided, so you don’t need to supply the SessionId unless you’re trying to contact OTHER sessions.

Try using **`system.perspective.*`** functions from a Python resource in the Webdev module. For instance, if you try to **`system.perspective.print()`** to debug variables, parameters, etc, I get this error: **`No perspective session attached to this thread`**. How I overcame this was to specify the sessionId AND the pageId (one of the things I missed which I found later in the docs is that if the sessionId is specified, the pageId MUST also be specified).

Can the problem be that this view does not have any sort of authentication? As in, when I open this Perspective view (Launch Session), I don't need to log in.

---

<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:** [November 5, 2020, 9:40pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/9 "2020-11-05T21:40:44Z")

</div>

> [@YF129701](#):
>
> That returns a pageId like **`NativeDocuments/NativeDocumentEditor`**

In the Designer. This is not the value you'll see in a true session. You only see this value in the Designer because it's using a "fake" or "mocked" page. In the Designer, this IS the expected value - there is no alpha-numeric `pageId` value within the Designer.

> [@YF129701](#):
>
> Try using **`system.perspective.*`** functions from a Python resource in the Webdev module.

I didn't realize you were using the function outside of the Page/View. Yes, other locations do not have the required "context" of the session and/or Page, so you do need to pipe that along.

---

<div class="post-metadata">

**Author:** ![YF129701](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/yf129701/32/60498_2.png) [@YF129701](https://forum.inductiveautomation.com/u/YF129701)\
**Post date:** [November 5, 2020, 9:46pm UTC](https://forum.inductiveautomation.com/t/perspective-session-id-not-unique/39712/10 "2020-11-05T21:46:57Z")

</div>

> [@cmallonee](#):
>
> In the Designer. This is not the value you’ll see in a true session. You only see this value in the Designer because it’s using a “fake” or “mocked” page. In the Designer, this IS the expected value - there is no alpha-numeric `pageId` value within the Designer.

Ok, I should've thought of trying that out... Thank you @cmallonee!
