WebSession.Available
From Xojo Documentation
Determines if the code is executing within a Session or not.
Notes
Some events do not execute within any user Session because they were not executed in response to a user action. For example, the WebApplication class events are not associated with any particular user and therefore there is no Session available. You can also determine if the code is executing in a Session by checking the Session object to determine if it is nil or not. However, the Available function executes much faster.
Example
This very simple example displays a message box only if a session is available. Without the Session.Available test, the Session.MsgBox call could generate a NilObjectException depending on the calling code. For example, calling Session.MsgBox from WebApplication.Open would cause a NilObjectException because there is no Session while WebApplication events are executing.
See Also
SessionNotAvailableException, WebApplication.SessionForControl, WebApplication.SessionForControlID, WebApplication.SessionCount, WebApplication.SessionAtIndex, and WebApplication.SessionWithIdentifier.