How to set a Cookie with UnityWebRequest?

I have difficulties using UnityWebRequest with Cookies. My webserver uses authentication and returns a Response Header “Set-Cookie” with a key-value pair. Unfortunately making more requests after the first authentication request, the Cookie is not stored by UnityWebRequest and therefore the requests are not permitted.
Sadly it is also forbidden to set a request Header myself with the Name “Cookie”.

Am I doing something wrong here? Or is this currently a known Limitation?

Thanks in advance!

You should use a call like this:

SetRequestHeader( "Cookie" , string.Format("session={0}",token) );

I haven’t tested this line, but if it doesn’t work you should report a bug and send me the bug number using the support portal.

There is a forum thread were you could give more information with multiple links and suggestions for workarounds:

Hey I am having similar kind of problem but i fixed it with SetRequestHeader and GetRequestHeader(“Set-Cookie”) but the problem is it is not working in WebGl Version since browser doesn’t allow the Access of Set-Cookie Header is there any way i can get around this problem