Dear all,
I would like to identify when a Perspective session (web page or app) starts up and shuts down.
My goal is to write to a tag when the session starts and when it ends.
I’ve tried using the session startup and shutdown events, but my script doesn’t seem to work.
Has anyone successfully used session startup or shutdown events in Perspective?
Any suggestions or examples would be greatly appreciated!
Add some logging to both events and make sure you see a corresponding entry in the logs (go to your gateway's webpage, and find the log page. It's in the "status" section).
Apologies for the confusion — my end goal is to write to a specific tag when a particular session is closed. I tried several if instructions but the ones I really need don't work
Are you sure the session had closed when you checked? Have a look in the status page of the Web portal at the perspective sessions running. A session does not end simply when you close the browser tab running a client. After that it waits for the session timeout before the session running in the gateway shuts down
Nick's point is that closing a browser tab, or closing the browser entirely, does not end the session. Browsers don't tell webservers when they close, so the gateway cannot close the session immediately. It has to time out.
Your desire to act on session close is misguided/impractical. Find another way. (Share why you think you need this.)
Your script has a syntax error. Case-sensitive variable name, it seems.
To answer why your script isn't working though: when the shutdown event fires, the session is already gone, so getSessionInfo doesn't contain the session anymore
Going back a step though, with the actual code you've got, it seems superfluous to be looping through the sessions at all, when at the end of it all it's doing is writing the session id to a tag. Can't you just skip the loop and just write the session.props.id to the tag? Unless of course there's some other logic you want to do that you haven't shown.