From Xojo Documentation
|This class is only available for Web applications.|
New in 2010r4
Session refers to two things in your web projects. The Session class in the project is a subclass of WebSession that you can use to add your own properties, methods and constants. Each user that connects to the web app gets their own instance of the Session class, which can be conveniently accessed using the Session method. To learn about the Session class, refer to the WebSession class.
This topic discusses the Session method that provides you with a reference to WebSession for the active user.
Session.property = value
|Property||Any valid property of the WebSession class or the Session subclass in the project.|
|Value||A value of the proper datatype for the Property.|
|Method||Any valid method of the WebSession class or the Session subclass in the project.|
|To refer to the current Session from within the Session object, use Self instead of Session as the prefix, especially in the Opening event because it may return Nil.|
In order to see WebSession properties in the debugger, you can create a temporary variable:
The reason for the pragma is that the call can be very expensive when there are lots of sessions running. This way it'll only affect performance when you're debugging.
To determine if a session is available for use, call WebSession.Available rather than comparing against Nil, as the Available method is more efficient and about four times faster.
Var user As String
user = Session.UserName // your own property added to Session
Multiple Browser Windows
This code saves the User Name and Password from a login page to properties added to the Session class:
Session.Password = PasswordField.Value
This code gets the current session associated with a web page: