Session Across Multiple Modules

Session Across Multiple Modules

Hi every1,

i have a secario where i have a login screen in 1 module after which the user will be routed to their sepcific module based on their role. i need the app to maintain a session variable in the app throughout the module and not having to parse ard the session variable.

could some1 please guide me on this portion?

Hi Hitesh

In OutSystems a Session is created in the first request the end-user makes to the Platform Server and allows to keep context during the end-user interactions with the server. The session consists in the set of session variables defined in the modules the end-user accesses during its interaction.

This means, your app will maintain the session.

More info about user session here:

Please let me know if you need further help



You can share session variable values, using as output of one public action that can be consumed in your module.

Hope it helps you!
Best regards.

Daniel Martins

Thanks Vera and Daniel Martins for your suggestions.

Daniel just a quick question, 

1. Does that mean i would need to hold this session in a Temp Entity?
2. And each time i log out or close the browser i would need to clear this entity?

Hi Hitesh

In case you decide to hold this session in a Temp Entity, you can use to System Event OnSessionStart, and clear your previous "session data on temp entity" when a new session starts. 

Hi Vera,

thanks for ur suggestion, Let me share with u my implementation, and maybe u can provide me with some advice?

Base Module: <-- could reside in the Library or Core layer of the Architecture
1. Has an Account entity which stores details of the user (etc. username, password)
2. Has  Login Action which checks the Users exsist 
3. followed by a a Start Session Action
4. This Start Session Action ---> all it does is assigns the values to the Session Vriable that i created
5. When user navigates to another module wat the happens is the 1st screen will get the session from the base class via a GetSession Method

Thanks and Regards,
Hi Hitesh,

At the moment i'm using a similiar logic like yours.
I have a generic login espace where I login all the users and after that forward them to specific espaces.
If you use the login action to login the users after that the users session variable (user Id) will be kept by the server cross all espaces. You just need to redirect on the flow wherever you want the user go and all the normal login on that espace wiil work and you don't need to provide the user credencials again until you log out or the browser clean the session variable.

One question: how you are you assigning the user session variable value?  A normal assign or using the Login action? 

Hi Gonçalo Azambujo,

Thanks :)

Here is a screenshot of how i used it, i Assigned it to the Session Variable i created. Please take a look and Advice.

JUst would like to add that i have to use Grant Permission action to grant the user so that the user can access that particular module Web Screens. As not every1 can access All Modules.

Thanks & Regards,

Hi Hitesh,

I think you built some actions you don't need because the platform already provide you that actions by default.
The Login action from the platform will already verify if you user exist or not and do the login if the username and the password match with what's on the database. After that will create (automatically) a session UserID that will be available all over the espace from that server. In this case, all the logic you want to do (save info, or chech info) for that specific user you can do it on the end espace where he will reach using function from the main espace. The permission you can give after the login action on the Login espace. 


The session is shared across multiple modules as long as they have the same User Provider. Check the information here.

Hmmm...I must be missing something too. I have three modules: theme, data and ui. They all share the same user provider (users).
I created a Session.debug (Boolean) that I could use to turn on and off extra information. It works within a module, but not across. E.g. The ui module uses a webblock and function from data but Session.debug isnt updated in that module.

I defined the Session.debug in each module. Is that correct? I didnt see it come over like other vars, structs, entities, etc.

Any help is appreciated.
Can you share your modules?
You should define the session variable in one module only and have APIs (public actions) that return that value to the other modules.

i can share at some point. But to be clear, youre saying that session variables cant be used across modules without public functions? Not that I'm opposed to that, I just want to be sure I understand. I thought that sessions were shared, but i did find it confusing that session vars arent "published" like other resources.


P.S. I'm reticent to share, because I've only been on out for about 2 months and I'm afraid of the feedback ;-> And I'm probably building something more complex that I should be...Can I send it privately?
I'll follow up on PM
Hi, In outsystem once you login into the application, the application will maintain the session.

It means if you
 have a login screen in 1 module after which the user is routing to their sepcific module based on their role. then no need to maintain the session variable.
Hi Guys,

thanks for ur solutions it really help me. but just 1 question how can i invoke the Session Start if i cant pass in any variables/values after authenticating my user?

thanks :)
Hi Hitesh,

On Session Start event doesn't run after the login it runs when a session starts. If you want to run some logic after the user logs in you can simply execute a global action with that logic.