system.perspective.getSessionInfo
This function is used in Python Scripting.
Description​
Returns information about one or more Perspective Sessions. The information returned by this function is a combination of information available on the Perspective Sessions status page on the Gateway, and some Session props (id and userAgent). Exact fields are as follows:
Key | Value |
---|---|
userAgent | Information the device running the Session. The exact content returned by this key is based on the the browser/device running the Session. |
id | Either the Id of the Session (similar to session.prop.id) or if called from the Designer, returns the Designer's id, as listed on the Designers Status page located on the Gateway. |
username | Either the username of the logged in user if authenticated, or "Unauthenticated" if an unauthenticated Session. |
project | The name of the project running in the Session. |
uptime | The number of milliseconds that the Session instance has been running. |
clientAddress | The address of the Session. |
lastComm | The number of milliseconds since the last communication from the Gateway. |
sessionScope | Where the Session is running. Possible values are: designer, browser, iOS, or Android. |
activePages | The number of active pages. |
recentBytesSent | The number of bytes last sent by the Session to the Gateway. |
totalBytesSent | The total number of bytes sent by the Session to the Gateway. |
pageIds | An array of page IDs that are currently open in the Session. |
authorized | Whether or not the user was authorized when gathering Session information. This will be true if the user was authorized. |
Syntax​
tip
This function accepts keyword arguments.
system.perspective.getSessionInfo([usernameFilter], [projectFilter])
Parameters​
Type | Parameter | Description |
---|---|---|
String | usernameFilter | A filter based on logged in user. [optional] |
String | projectFilter | A filter based on the project name. [optional] |
Returns​
List - A list of objects (PyJsonObjectAdapter).
Scope​
Gateway, Perspective Session
Code Examples​
Code Snippet
# This code counts the number of times a user named "billy" is logged in.
sessions = system.perspective.getSessionInfo("billy")
print "Billy has %d sessions" % len(sessions)
Code Snippet
# This script gets all sessions using the "MyProject" project and displays information about them.
# Get the Session info.
projectResults = system.perspective.getSessionInfo(projectFilter="MyProject")
# Loop through the sessions.
# Enumerate() gives both the Session object and the index.
for index, sessionObj in enumerate(projectResults):
# Print session info
print "Session", index, ": username: ", sessionObj["username"], "uptime: ", sessionObj["uptime"], " seconds"