Skip to main content


persistent class OAuth2.Server.Session extends %Library.Persistent

SQL Table Name: OAuth2_Server.Session

The OAuth2.Server.Session class is the default SessionClass which is included with the server. The default class will use httpOnly cookies to maintain the session.
The SessionClass is specified in the Authorization Server Configuration. The SessionClass must contain GetUser, Update, Login and Logout methods with signatures as specified in this class.

Property Inventory

Method Inventory


parameter COOKIENAME = CSPOAuth2Session;
The name of the cookie used to maintain the session


property AuthTime as %Integer;
The time when the user was authenticated.
Property methods: AuthTimeDisplayToLogical(), AuthTimeGet(), AuthTimeGetStored(), AuthTimeIsValid(), AuthTimeLogicalToDisplay(), AuthTimeNormalize(), AuthTimeSet()
Cookie that is used to track the session.
Property methods: CookieDisplayToLogical(), CookieGet(), CookieGetStored(), CookieIsValid(), CookieLogicalToDisplay(), CookieLogicalToOdbc(), CookieNormalize(), CookieSet()
property Expires as %Integer;
Expires is the time in seconds from beginning of the Unix epoch when the session expires. If Expires="", then session does not expire.
Property methods: ExpiresDisplayToLogical(), ExpiresGet(), ExpiresGetStored(), ExpiresIsValid(), ExpiresLogicalToDisplay(), ExpiresNormalize(), ExpiresSet()
property Scope as %String (MAXLEN = 1024);
Scope is the blank separated list of scopes permitted for this user in this session.
Property methods: ScopeDisplayToLogical(), ScopeGet(), ScopeGetStored(), ScopeIsValid(), ScopeLogicalToDisplay(), ScopeLogicalToOdbc(), ScopeNormalize(), ScopeSet()
property Username as %String (COLLATION = "EXACT");
User that is logged in by this session.
Property methods: UsernameDisplayToLogical(), UsernameGet(), UsernameGetStored(), UsernameIsValid(), UsernameLogicalToDisplay(), UsernameLogicalToOdbc(), UsernameNormalize(), UsernameSet()


classmethod GetCookie() as %String
An overridable method to obtain the cookie. This allows easy change of the cookie format.
classmethod GetUser(Output scope As %String, authTime As %Integer, Output sc As %Status) as %String
The GetUser method returns the name of the user currently logged into this session. If no session exists, then "" is returned.
classmethod Login(username As %String, scope As %String, interval As %Integer, Output authTime As %Integer) as %Status
The Login method creates a new session for the user named by username.
The scope argument specifies a blank separated list of scopes that this user is authorized for. The interval argument is seconds until expiration for the session. If interval=0, then the session will not expire.
classmethod Logout()
The Logout method terminates the current session. It is not considered an error to have no current session.
classmethod MakeCookieValue() as %String
An overridable method to create a new cookie value. This allows easy change of the cookie format.
classmethod SetCookie(value As %String, expires As %Integer)
Set the cookie.
classmethod Update(scope As %String, interval As %Integer) as %Status
The Update method updates the existing current session. The blank separated list of scopes in the scope argument updates the scopes associated with the session. If the interval argument is specified the session interval is updated. The interval argument is seconds until expiration for the session. If interval=0, then the session will not expire.


index (CookieIndex on Cookie) [IdKey, Type = key, Unique];
The IDKEY for the session class.
Index methods: CookieIndexCheck(), CookieIndexDelete(), CookieIndexExists(), CookieIndexOpen(), CookieIndexSQLCheckUnique(), CookieIndexSQLExists(), CookieIndexSQLFindPKeyByConstraint(), CookieIndexSQLFindRowIDByConstraint()
index (ExpiresIndex on Expires);
Order by time
Index methods: ExpiresIndexExists()
index (UserIndex on Username);
The session is indexed by the Username
Index methods: UserIndexExists()

Inherited Members

Inherited Methods


Storage Model: CacheStorage (OAuth2.Server.Session)

FeedbackOpens in a new tab