0

I have several different form applications where each form page is a separate application. The user answers questions on one page, then navigates to another to continue filling out the form.

I need to post custom data from a form in various applications to one server. (For example using ajax). How can I figure out that this is one user to write data into one database record? Do I need to use cookies or something else?

EDIT: I distribute my js package to clients, and I need to implement this without affecting anything other than this js package.

EDIT: I got the idea to generate and retrieve cookies from my centralized application using an iframe, like Facebook does with a Like button.

Can I, on the first visit to the form on one of the applications, create an iframe using js and generate a UUID for the user, write it to a cookie, and on another page of the form, request these cookies with a uuid

RomanOks
  • 692
  • 3
  • 13

1 Answers1

1

When a user visits your page, generate a unique identifier (e.g., a UUID, here's an example of how to generate one) using JavaScript and store it either as a cookie or in local storage. Send that along whenever you send a request to the server.

Dennis Hackethal
  • 13,662
  • 12
  • 66
  • 115
  • Thanks for the answer. So these cookies will be visible on different domains, right? – RomanOks Aug 03 '20 at 06:20
  • I think both local storage and cookies are bound to specific domains, but [people have found workarounds for that](https://stackoverflow.com/a/3342225/1371131). – Dennis Hackethal Aug 03 '20 at 06:24
  • Can you please tell me what to do if these various applications are not mine? That is, I distribute my js package to clients, and I need to implement this without affecting anything other than this js package. Thanks. – RomanOks Aug 03 '20 at 06:38
  • Possibly. You could write a JS package that implements the necessary redirect following [this approach](https://stackoverflow.com/a/3342225/1371131). You'd need a central domain that keeps track of cookies, have your JS package send users to it, and then redirect back using the information (e.g. UUID) you require and (presumably) run other code in your JS package with that information. – Dennis Hackethal Aug 03 '20 at 06:45
  • I'll need to deal with it. Thank you for your help! – RomanOks Aug 03 '20 at 06:48