Is it possible in php to return the answer and continue to work in the background. For example: we send ajax a request to register a new user, we receive data in php, we write it to the database, we give the user id in ajax, the client is automatically logged in, and php sends mail with an account verification link, and something else
- If you want perversions, then you can. But is not it easier in the script with authorization to immediately send mail if the user is found? Or do the 2nd ajax to send mail - ArchDemon
- I think this is not a problem. but there are many nuances. I see it like this, you are sending an asynchronous request that executes the chain. it clings to the models you need in turn, at which time your instance with which the user works continues to perform actions - if everything is successful, then the data is returned to the user, in particular, the session is overwritten and when updated and transitioned - it will already be authorized. But it is a crutch on asynchronous requests. I think experienced users will offer the best option - mydls1
|
1 answer
Rather than it is possible.
The server will return a response with the id of the new user and the current php process will end there.
But, you can send a new ajax from the client after the first one, which should send a letter. Or, best of all, put the task in the queue (rabbitmq, kafka). Queue to process separate vorker.
|