How to make POST (API) request with cookies inside controller | Laravel 9.x

I’m working with Omada Controller (External Portal Server). That is, to register users through the EAP. The device must be allowed to use WiFi.
I use following documentation:

https://www.tp-link.com/ru/support/faq/3231/
I tested the requests through Postman. Everything is working. However, it is necessary to send a cookie in the request to authorize the device after logging in.

I wrote the following code in Laravel. but cookies are not being stored or sent.

public function AuthFree(Request $req)
    {
        $inputs = $req->all();
        //IP Address of Controller
        $endPoint = 'https://CONTROLLER_API:PORT/CONTROLLER_ID/api/v2/hotspot/extPortal/auth';
        $operatorData = self::getCSRFToken();
        $csrfToken = $operatorData->object()->result->token;
        $cookies = $operatorData->cookies()->getCookieByName('TPEAP_SESSIONID')->toArray();//->getValue();
        $deviceBody = [
            'clientMac' => $inputs['clientMac'],
            'apMac' => $inputs['apMac'],
            'ssidName' => $inputs['ssidName'],
            'radioId' => inputs['radioId'],
            'time' => 1859960742,
            'authType' => 4,
        ];

        $authDevice = Http::withCookies($cookies, $endPoint)
        ->timeout(30)->withOptions([
            'verify' => false,
        ])
        ->withHeaders([
                'Content-Type' => 'application/json',
                'Accept' => 'application/json',
                'Csrf-Token' => $csrfToken,
            ])
            ->post($endPoint, $deviceBody);
        dd($authDevice);
    }

//Login operator.
public function getCSRFToken()
    {
        $authOperator = Http::accept('application/json')->timeout(15)->withOptions([
            'verify' => false,
        ])
            ->post('https://IP:PORT/ID/api/v2/hotspot/login', [
                'name' => 'USERNAME',
                'password' => 'PASSWORD',
            ]);
            
        return $authOperator;
    }

Also i wrote as following code:

$ch = curl_init();
        // Set return to a value, not return to page
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        // Set up cookies.
        curl_setopt($ch, CURLOPT_COOKIEJAR, request()->cookie('TPEAP_SESSIONID'));
        curl_setopt($ch, CURLOPT_COOKIEFILE, request()->cookie('TPEAP_SESSIONID'));
        // Allow Self Signed Certs
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
        // API Call
        curl_setopt($ch, CURLOPT_URL, $url);
        curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($authInfo));
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $res = curl_exec($ch);
        $resObj = json_decode($res);
        return $resObj;

But this also returns error.

The operator enters the system and receives a token through the getCSRFToken function mentioned above. A COOKIE is returned along with the token. I need to send TOKEN and COOKIES together to authorize the device.
Meanwhile, the getCSRFToken function is running and returning tokens. But authDevice is returning an error. Because it can’t get Header and Cookies.

My question is: How can I save the cookies and how can I add them to the request and send them?

Is there something wrong with the code I wrote?