Skip to main content
Version: 8.1

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:

KeyDescriptionValue
userAgentDetails about the device or browser running the Session.String
idThe Session ID (or Designer ID if called from the Designer).String
usernameThe logged-in user's name or "Unauthenticated" if the Session is not authenticated.String
projectThe name of the project active in the Session.String
uptimeThe time (in milliseconds) the Session has been active since creation.Integer
clientAddressThe IP address or hostname of the client running the Session.String
lastCommThe time (in milliseconds) since the last communication with the Gateway.Integer
sessionScopeThe environment where the Session is running: Designer, Browser, iOS, or Android.String
activePagesThe number of pages currently active in the Session.Integer
recentBytesSentThe number of bytes sent to the Gateway in teh most recent communication.Integer
totalBytesSentThe total number of bytes sent to the Gateway by the Session.Integer
pageIdsA list of the IDs of pages currently open in the Session.List
authorizedWhether 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​

TypeParameterDescription
StringusernameFilterA filter based on logged in user. [optional]
StringprojectFilterA 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"