0

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.

sideshowbarker
  • 62,215
  • 21
  • 143
  • 153
JohnDoe
  • 349
  • 4
  • 15

2 Answers2

1

It is possible to get cookies to share between two domains, though you'll have to do some extra work with the service that creates the cookie. See this answer for more details on how that works.

On the Grav side, you're correct. You'll need to implement a plugin (see the dev-tools plugin) that will then read this cookie. If I were doing the project, I would setup the plugin to store the cookie info as a twig variable.

Alternitively, your plugin could simply read from the DB.

Jacobm001
  • 4,032
  • 4
  • 29
  • 49
  • Thanks for the answer Jacob! I need grav to create the cookie, but i'm guessing I still need to implement a plugin, which can create this cookie. Then i might not need to store it as i twig variable. I'll be looking into this problem tomorrow and then i'll post my findings here. – JohnDoe Oct 24 '17 at 19:13
0

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.

JohnDoe
  • 349
  • 4
  • 15