2

The links you can get on google and stackoverflow are very old (2009).

Between 2009 and today, a lot of things have been solved / improved.

So my question is: how to get/set cookies using UnityWebRequest with the latest Unity version?

Olivier Pons
  • 14,839
  • 25
  • 109
  • 203

2 Answers2

1

You can use SetRequestHeader and GetRequestHeader/GetResponseHeader to set and get cookies on your WebRequest.

//the key is case sensitive
UnityWebRequest.SetRequestHeader("Cookie", "Delicious cookies");
UnityWebRequest.GetRequestHeader("Cookie");
Remy
  • 4,573
  • 4
  • 28
  • 57
0

Thanks to rider, here's my working code: in the foreach loop you can get all the values, hence I got the Set-Cookie value I needed.

foreach (var s in www.GetResponseHeaders()) {
    Debug.Log("s=" + s);
}
Olivier Pons
  • 14,839
  • 25
  • 109
  • 203