0

If I have a PHP script that makes two curl calls like so:

  1. set a variable
  2. get the value of the variable

What happens if two or more users call that script simultaneously?

Say user one sets the variable to "dog" and user two sets it to "cat". Will the two requests of one user always be executed together or could this happen:

user one: set var to "dog" user two: set var to "cat" user one: receive value "cat" user two: receive value "cat"

And if this is the case, is there any way for me to prevent it from happening? Keep in mind that I do not have direct control over the variable that is being set.

1 Answer 1

2

Http is state less protocol. You can not set any value to variable for permanent . It will clear all the data variable value once its response has been completed. if you want to do this you can manage using php session.

Sign up to request clarification or add additional context in comments.

3 Comments

This is an RPC call to a different process and the variable is set semi permanently, as in it remains for as long as the process runs. I know for a fact that if user one sets the variable to "dog" and user two only reads it that the curl request will return "dog".
@vomoto you want to set and get value on singe curl request?
I want to ensure that user two cannot set the value until after user one has requested it. But I don't know if that is even an issue because I don't know in which order curl requests are executed. If all requests of user one are performed before those of user two this is no problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.