onSessionCreated Session Event


The onSessionCreated system event, which fires when a new session is created in IIS and Alpha Cloud, can be used to add Xbasic for setting up session variables.


In a typical application, session variables are created when the user logs in. In the Security Framework, this is usually done on the redirect page defined in the Security Framework. When the user logs in, they are redirected to the redirect page (e.g. "redirect.a5w") where session variables are created for the user. After the session variables are created, the user is then redirected to the main application.


If an application has been configured to use Windows Integrated Login or Certificate-based Login, there is no login page. Because there is no login page, there is also no redirect page that can be used to create session variables for the user.

In this situation, the onSessionCreated system event can be used to configure session variables for the user. The onSessionCreated event is an event available under IIS and in the Alpha Cloud. To create one, you must define an Xbasic Module named SystemOnSessionCreated (see Xbasic Modules for information on how to create an Xbasic Module).

You MUST save the Xbasic Module with the name "SystemOnSessionCreated" in order to use the onSessionCreated system event to your application.

In this Xbasic module is where you will define the Xbasic to execute whenever the onSessionCreated event is triggered.

The Xbasic module must export a function named onSessionCreated. For example:

function initializeSessionVars as v ()
  ' Add code to initialize session variables
  Context.Session.Add("variableName", "variableValue")
end function

exports.onSessionCreated = initializeSessionVars

The onSessionCreated event is triggered when a new session is created. A session is created the first time a call is made to the Application Server or on successful login. A session is also created if the session times out between callbacks to the Application Server or if Context.Session.Abandon() is explicitly called.

onSessionCreated is only available on IIS and Alpha Cloud


IIS and Alpha Cloud Only