Sharing data between components

Enonic version: 6.5.3
OS: Ubuntu

I need to share data between components in different applications. I thought about using a session, but i haven’t found any documentation about sessions in javascript, and I’ve only found this class SimpleSession in the Javadoc by googling (which i dont know how i would go about implementing).

Is there any clever way of sharing data between components/applications scoped to session and/or user?

Could you provide some more info on the use case?

You can get content from other apps. For example, with a ContentSelector, you use something like <allowType></allowType> and it’s the same with contentLib.query({...}) for getting content of a type from another app. Ideally apps would be loosely coupled and independent, but there are always special cases.

In this spesific case i was looking into making a paymentapp with a part that rendered a card detail form.

The payment module only cares about what amount it should charge, and a description of whats being charged.

To make it completly decoupled, and allow it to be integrated into anything (donation pages/webstores/one click buy++), i would like to retrieve this data in the component controller backend.

I found a workaround using a simple content-type (which can be extended), but it forces a contenttype that might not fit everyone, and intergration into already existing pages requires bigger changes. Thats why i wondered about storing it in a session, but couldn’t find a way of doing this.

I suppose you could add a service that provides what you need to whatever site you add the payment app to. Then you could access the service in the payment app part with the http-client library. That way at least the payment app would be modular and could added to any site without modification. But any site it’s added to would need the service.

sounds like you should create a service for this, If I understand the use case though…

I have a service to process the payment, which is being called from the card details form.

If i am to use this service to get details (amount/description) about the purchase as well, i would need to call it backend from another part. They cant be send frontend due to the obvious reason that the client can set its own amount. I also dont want the user to implement the card detail form themselves, since it processes the details and sends a token+++, it wouldn’t be very much of a plug and play app.

So, if i call this service from another parts controller, how would i store it waiting for the next call (with card details) and how would i make sure its the same session sending in the purchase details and then card details?