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 | Description | Value |
---|---|---|
userAgent | Details about the device or browser running the Session. | String |
id | The Session ID (or Designer ID if called from the Designer). | String |
username | The logged-in user's name or "Unauthenticated" if the Session is not authenticated. | String |
project | The name of the project active in the Session. | String |
uptime | The time (in milliseconds) the Session has been active since creation. | Integer |
clientAddress | The IP address or hostname of the client running the Session. | String |
lastComm | The time (in milliseconds) since the last communication with the Gateway. | Integer |
sessionScope | The environment where the Session is running: Designer, Browser, iOS, or Android. | String |
activePages | The number of pages currently active in the Session. | Integer |
recentBytesSent | The number of bytes sent to the Gateway in teh most recent communication. | Integer |
totalBytesSent | The total number of bytes sent to the Gateway by the Session. | Integer |
pageIds | A list of the IDs of pages currently open in the Session. | List |
authorized | Whether the user was authorized when the Session data was retrieved (True or False) | Boolean |
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"