Here is a really basic overview of how cookies work.
Client (browser) makes a request
The server sees the request and asks: "Hey, did this client send me cookies?"
The server does not see the cookie, so it takes some action and then sends a response with the cookie
The client (browser) sees the answer and says: "Hey, look, cookies for me, I better save him"
The next time a client sends a request to the same server, it will send the same cookie
The server sees the request and asks: "Hey, did this client send me cookies?"
The server sees the cookie this time and does some different things because of the cookie, and then sends a response with the cookie
The client (browser) sees the answer and says: βHey, look, cookies for me, let me update the one I haveβ
It seems that the problem you are facing is that you have multiple curl requests running on the same computer, but you want each one to use a different cookie.
You should be able to achieve this using the following two curling options.
CURLOPT_COOKIEJAR //tells curl which file to save the cookie from the server in CURLOPT_COOKIEFILE //tells curl which file to look in and send as the request cookie
If you configure the system so that every other hang request sets a different path value for these two parameters, you must be set.
source share