send data from a PHP (service) page to unity webgl

Hello everybody.

I have a PHP script that reads data from a previously set cookie in the browser (using setcookie). I would like to consume that service from my unity application (game if you wanna call it) and use it to retrieve some user data .
I’ve been using the following c# script to use the service:

public void SendLoginData()
  {
   // here im calling the service url!
    var cu_get = get("http://localhost.com/survey/cookietest.php");
 
  
    var data = cu_get.text;

    }

     public WWW get(string url)
{
    // Create the WWW object and provide the url of this web request.
    WWW www = new WWW(url);

    // Run the web call in the background.
    StartCoroutine(WaitForRequest(www));

    // Do nothing until the response is complete.
    while (!www.isDone) { }

    // Deliver the result to the method that called this one.
    return www;

}

// Run the web call and deliver the result as it is arriving.
private IEnumerator WaitForRequest(WWW www)
{
    yield return www;
}

however, the result to this urls is that the cookie hasnt been set.
this is my PHP script.

  $cookie_name = "cookie";
    if(!isset($_COOKIE[$cookie_name])) {
     echo "Cookie named '" . $cookie_name . "' is not set!";
  } else {
   //  echo "Cookie '" . $cookie_name . "' is set!

";
// echo "Value is: " . $_COOKIE[cookie_name]; echo _COOKIE[$cookie_name];
}

if i try that ulr from browser it prints the value of the cookie. but it’s not working from unity,

Any ideas on what could i be missing?

Thanks !

your problem is this, in 5 above

var data = cu_get.text;

you cant assign the data right away because it hasnt been loaded yet from the get.