I am using Guzzle from my Laravel application to CURL in to another PHP application.
The problem I am having is that after making a subsequent CURL request, the session is not being persisted. This makes sense of course - since every CURL request will be a unique session.
So for example, in my target application, suppose I do this:
$_SESSION['action_id'] = 1234;
Then in my next request, I want to do:
$action_id = $_SESSION['action_id'];
I get an undefined index error. I have looked at the documentation page on cookies (https://docs.guzzlephp.org/en/latest/quickstart.html#cookies), which says:
You can set cookies to true in a client constructor if you would like to use a shared cookie jar for all requests.
So I have tried that as follows:
$client = new \GuzzleHttp\Client(['cookies' => true]);
But that didn't make any difference. In my target application, if I do var_dump($_COOKIES['PHPSESSID'])
it returns null
. $_COOKIE
is always empty itself. If I do var_dump(session_id())
I get a different value every time. So this is where the problem lies - I need to have access to the same session when I make a subsequent request.
Does anyone know how I can accomplish this?