OnSessionStart - Be aware

Hi all,

I had an issue using the OnSessionStart event because I assumed something and my assumption was wrong, so I decided to write this post in the community to warn everybody not to make the same mistake.

The scenario is:
- 1 espace user provider (single tenant)
- 20 espaces that share that user provider (all single tenant)
- 1 multi tenant espace that is SELF user provider (but consumes some entities and actions from the other espaces)

Recently, we decided to use the OnSessionStart event to fill some session variables in each of the 20 single tenant espaces. So I wrote the code and copy/pasted it to all of them. No problem here and each of them worked fine.

The problem began when the multi tenant espace started to have unexpected behaviours. And I hadn't published it for a while, so I was puzzled.

I finally figured it out. When the multi tenant espace called a public action from one of the others, the OnSessionStart event of that espace was being executed. I wasn't expecting that. I assumed that the OnSessionStart of an espace would ONLY be executed if THAT espace was being accessed directly and not through a public reference.

So, I had to correct the OnSessionStart in all 20 espaces to include a validation: IF entryEspaceName = multi-tenant espace THEN do nothing ELSE execute the code.

I hope this will be of some help to all of you.
I have a request to the OutSystems staff, though. Could you include this warning on the HELP of the OnSessionStart event? There is nothing on that help that says explicitly that this happens.

best regards
Hi Gonçalo,

thank you you for the heads up. We'll look into it and add it to our backlogs.

Great contribution!

Hello Goncalo,

With the onsession start action, be aware (mostly for applications that use public accessible screens) that it is called 'again' (since when you vistit the application it is will be executed and after login again) when a user login to the application.

Kind regards,

Hi Andre,

Has this item on the backlog been implemented?

I ask this, because I just had the opposite behaviour from what Gonçalo described. We have a global theme with an OnSessionStart that loads some generic data in the session. When I login to the application that uses this theme, the OnSessionStart of the Theme runs correctly and the application works.

The problem is that when I logout and login again, the OnSessionStart of the Theme is skipped and I get an error loading the first page that uses the generic session variable.

I'm using platform 9.1.603.0

Kind regards,


Hi Remco,

The backlog item was for the documentation and not for the product. If you find the behavior is not aligned with what is described in the help please submit a ticket to support.