30
Views
4
Comments
Pass a client variable between modules running in different domains

Following the discussion https://www.outsystems.com/forums/discussion/103348/pass-a-client-variable-between-modules-with-different-user-providers/ the solution presented that allows ModuleB to access the client variable ValueX of ModuleA

           localStorage.getItem('$OS_UserProviderM$ModuleA$ClientVars$ValueX');  

works if both applications run under the same domain.

However, if ModuleA runs under domain DomainE.com and ModuleB runs under domain DomainF.org, how can ModuleB access the client variable set in ModuleA? Is it even possible?

2025-08-07 06-30-56
Amit J
Champion

As I mentioned there already 

If domain is defferent then use Shared Storage via Server

When ModuleA sets ValueX, also persist it server-side (DB, cache, session, Redis, etc.)

ModuleB fetches it from the server.

This bypasses the client isolation completely.

Best option if you control both apps and need reliabilit

2022-02-09 17-18-50
Rafaela Azinhal

Hi. Thanks for your reply.

I'm already persisting it server-side - it is a kind of user session: a user is authenticated in ModuleA , which saves the user session key in a client variable and persists it server-side, and then redirects the user to ModuleB. How can ModuleB get the data from the server for that user only, considering there are other user sessions?

2024-10-12 12-11-20
Kerollos Adel
Champion

hallo @Rafaela Azinhal  , 

One possible solution is to store the client variable in a module (for example, in a UI module) and then pass it to any other module that requests it.

  • You can save the variable in the UI module.

  • For each screen or action that needs this value, pass it as a parameter.

This avoids the limitation of localStorage across different domains and ensures the variable is always available wherever it is required.

2019-01-07 16-04-16
Siya
 
MVP

@Rafaela Azinhal :  localStorage is origin-scoped (scheme + host + port). A key written at https://DomainE.com/ is not accessible to code running at https://DomainF.org/. This is enforced by the browser’s Same-Origin Policy and is unrelated to OutSystems.

If you must share the value client-side only, a common workaround is to embed an iframe in ModuleB that loads a tiny page from https://DomainE.com. That page (same origin as ModuleA) can read the needed localStorage key and send it back via window.postMessage to the parent on https://DomainF.org.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.