Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The first server routine called in the Server Module will typically be some kind of sign on routine which initiates the session and sets any required values to be used within the session:

     Begin_Com Role(*EXTENDS #PRIM_SRVM)
Persist Fields(#SessionUserID #SessionPassword)
 
SrvRoutine Name(Signin)
Field_Map For(*Input) Field(#User)
Field_Map For(*Input) Fields(#Password)
Field_Map For(*Output) Fields(#io$sts)  

If (#Com_owner.VerifyUser( #User #Password ))  

#Com_owner.StartSession Timeout(900)
#io$sts := OK  

* Store Persistent Data    
#SessionUserID := #User
#SessionPassword := #Password  

Else  

#io$sts := ER
 
Endif
Endroutine
 
SrvRoutine Name(DoSomething) Session(Required)
Field_Map For(*Input) Field(#User)  

If (#User = #SessionUser)  
* process request
Endif

  Endroutine
SrvRoutine Name(SignOut) Session(*required)
 
#com_owner.EndSession
 
Endroutine


The Signin routine has an implicit Session(*None) parameter meaning that no session is required to execute the routine. The User ID and Password are passed into the routine and assuming they're valid, are stored in variables that have been defined elsewhere in the source as persistent.

...

All subsequent routines will have Session(*Required). For added security, they may require the User id to be included. This can be compared to the persistent session data.


     SrvRoutine Name(DoSomething) Session(*Required) 
Field_Map For(*Input) Field(#User)

If (#User = #SessionUser)
 
Endif

Endroutine

When a SrvRoutine is executed, the necessary session data is passed to the server and tested to ensure that the timeout hasn't been hit. If it has, the Failed event will be fired in Visual LANSA and the stateful client side can respond accordingly, perhaps showing the sign on screen again.

Note
Note: You need to actually process this response to avoid Web Application has expired message.
     Mthroutine Name(DoSomething) Session(*Required)

Define_Com Class(#SessionServices.DoSomething) Name(#DoSomething)
 
#DoSomething.ExecuteAsync( #User )
 
Evtroutine Handling(#DoSomething.Completed)   
#MyApplication.ShowDetails
Endroutine
 
Evtroutine Handling(#DoSomething.Failed)
#MyApplication.ShowSignon
Endroutine
 
Endroutine

Note
Note: Time out policy when running in the Cloud.

...