I'm facing a problem with setting the sessionId cookie in the UnityWebRequest.
public static class CheckSession_LiveHandler
{
public static IEnumerator Send(APIRequest<CheckSession.Request> _request, APIResponse<CheckSession.Result> _onComplete)
{
Debug.Log("CheckSession_LiveHandler: " + _request.request.sessionId);
string endpoint = EnvironmentSettings.GetVariable<string>("ESCROW_SERVICE_URL");
using (UnityWebRequest request = UnityWebRequest.Get( $"{endpoint}/session"))
{
request.SetRequestHeader("Cookie", $"{sessionIdKey}={sessionIdValue}");
yield return request.SendWebRequest();
var data = request.downloadHandler.text;
CheckSession.Result result = JsonConvert.DeserializeObject<CheckSession.Result>(data);
if (request.isNetworkError || request.isHttpError)
{
[...]
}
else
{
[...]
}
}
}
}
The error in the browser console is as follows:
Refused to set unsafe header "Cookie"
We need to send the session cookie value to fetch user data related to the session.
The game is running on a WebGL client.
I've tried to modify the fetch function to include "credentials" in the options, but it doesn't work.
Do you know how I can send the cookie in the request?