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:

KeyValue
userAgentInformation the device running the Session. The exact content returned by this key is based on the the browser/device running the Session.
idEither 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.
usernameEither the username of the logged in user if authenticated, or "Unauthenticated" if an unauthenticated Session.
projectThe name of the project running in the Session.
uptimeThe number of milliseconds that the Session instance has been running.
clientAddressThe address of the Session.
lastCommThe number of milliseconds since the last communication from the Gateway.
sessionScopeWhere the Session is running. Possible values are: designer, browser, iOS, or Android.
activePagesThe number of active pages.
recentBytesSentThe number of bytes last sent by the Session to the Gateway.
totalBytesSentThe total number of bytes sent by the Session to the Gateway.
pageIdsAn array of page IDs that are currently open in the Session.
authorizedWhether 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​

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"