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.
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.
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.
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.
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:
You must make sure you have no windows open in the browser you are going to be using.
You must then wait for the period of time specified for your session timeout.
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.
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.
# as a binding
If you’re referencing the value in a script, you want to use self.page.props.pageId .
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.
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.
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.
Yes I see my mistake here (not correctly binding the pageId). I do get different pageIds from different sessions. See snip (binding a custom property to system.perspective.getSessionInfo()):
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 pageIds look like.
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.
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.
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.