Solved Whether the $_POST variable is reliable for a multiple PHP call?

Page A run js (ajax post) to call a back end php script PA and the script use $_POST['foo'] to get the parameter (assume here foo = 1024).

Page B run js (ajax post) to call a back end php script PB and the script use $_POST['foo'] to get the parameter (assume here foo = 2048).

If same user with same browser run Page A and Page B, the back end php script will get "foo = 1024" or "foo = 2048"?

Maybe that is a simple question, but I can't find related docs.
 
I'm not sure what you mean.

Each AJAX post will be to a separate PHP process, and those processes won't interact - is that what you mean? Page A and script PA and Page B and script PB won't have anything shared or any knowledge of each other.

There's no state in HTTP unless you use some sort of sessions or cookies.

Superglobals are as you say, per script.
 
If same user with same browser run Page A and Page B, the back end php script will get "foo = 1024" or "foo = 2048"?
It will get both.

One instance will get the HTTP header with foo set to 1024 (from page A)
Another instance will get the HTTP header with foo set to 2048 (from page B)

This is more about how http works rather than PHP - maybe that's why you are not finding what you are looking for in the PHP documentation:


HTTP is stateless: there is no link between two requests being successively carried out on the same connection. This immediately has the prospect of being problematic for users attempting to interact with certain pages coherently, for example, using e-commerce shopping baskets. But while the core of HTTP itself is stateless, HTTP cookies allow the use of stateful sessions. Using header extensibility, HTTP Cookies are added to the workflow, allowing session creation on each HTTP request to share the same context, or the same state.
 
Yes, I worded that poorly - maybe http request would have been better wording.

But think I’m correct in saying the OP’s question more to do with how HTTP works rather than PHP.

So how POST works:

 
Back
Top