Search code examples
phpcookiespostmessagegrav

Send data from one page (CMS) to subdomain (platform)


I hope, that you are able to help me, or at least give me a few suggestions for a solution.

Context: We have a grav CMS site containing general information, a blog etc (example.com). On a subdomain (test.example.com created in Ruby (backend) and Angular (frontend)) we have a fully developed two-sided platform.

The problem: I need to create a specific landingpage on example.com. This landingpage has to include a signup form, where i need to be able to read the entered data on a subdomain.

Ex: example.com/landing-page1 has a form which contains email, username and password. test.example.com is a fully developed platform, which has a sign-up flow. When submitting the form on example.com, it should open a new window with the test.example.com/sign-up, where the data from the form on example.com is read from.

As i see it, the best solution would be to create a cookie, which can be read from test.example.com. Is that possible?

To do this in grav, as i understand it, i need to create a plugin, that can create this cookie, and then i need to modify the platform so that it can read from the cookie. And i think i need to implement CORS as well to do this.

Any suggestions or help is greately appreciated.


Solution

  • I ended up with a different approach than above, so I could get out of creating a grav-plugin. I made the form on example.com send a GET-request to the subdomain, and through that passing the variables through the URL. Then i created a service to store this data, which i then injected in the angular modules, where i needed to access the data.