How can I run a database command whenever a database session is used, and then run another command whenever the session is released?
I understand that there is a pool of database sessions shared among users. For each request, a database session is assigned, and then released at the end of this request.
I'm using an Oracle database and I want to pass the user ID to the database session context:
I was able to do this for each server action but there is a large number of server actions. So I'm looking for a centralized solution where this is done in the background without developer intervention.
Hi Kahlil,
Have you taken a look at System Events?
In here you can centralize actions to run when a session starts (action to be executed in the first request to the server, after logging in, or on the first request after having logged out) or when a web request begins (action to be executed on each request to the server.), so you don't have to repeat it every time.
Note: this only applies for Traditional Web where session is maintained server side.
Hope it helps.
Regards,João
OnBeginWebRequest would have been helpful if not for the following:
Hi Khalil,
In mobile and reactive, you can take advantage of screen lifecycle events to control this (you have for instance the OnDestroy event to "undo what you did" in the OnInitialize / OnReady).
In order to avoid repeating the same actions for all screens, you can set those lifecycle events on the layout block.
In Traditional Web, you can also set your logic on the Preparation of your layout block.
Another limitation for OnBeginWebRequest: