TECH TIP: Start a New Web Session
The following example shows how to ask the global WebSessionManager to create a new session. This results in the aWebRequest.SessionID being assigned.
uses
rsWebSessionManager;
procedure TWebModule1.WebModule1waDefaultAction(Sender: TObject; Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
lWebRequest: TrsWebRequest;
lSession: TrsWebSession;
begin
{use the incoming request parameters to create a TrsWebRequest}
lWebRequest := rsWebTier1.CreateWebRequest(Request.QueryFields, Request.Content);
{get the web session, this will create a new session if needed}
if not rsWebTier1.SessionExists(aWebRequest) then
gWebSessionManager.GetSessionForRequest(lWebRequest);
ShowMessage(aWebRequest.SessionID);
end;