working with cookies On Android Devices

Hey everyone.

I have problems working with Cookies on the Android app im working on.
thing is i used WebRequest and WebResponse in order to send requests and get responses to my targeted server.

The first of all requests, is Authentication.
I send username and password, and i get a user token, AND, in order to stay signed in, i have to fetch a Cookie specifically named (Type “SessionID”), and use its value for further requests.
WebRequest and WebResponse classes, as far as i searched, does not support cookies. HttpWebRequest and HttpWebResponse but, does support cookies.

Porblem is that System.HttpWebRequest and System.HttpWebResponse are not under .Net 2.0, therefor, i cannot use them on Android devices.

what are suggestions ? is there any way around it ?

I Already found an answer.

   WebRequest request = HttpWebRequest.Create(host + uri);

    IEnumerator e = webAsync.GetResponse(request);
        while (e.MoveNext())
        {
            Debugger.LogWarning("Connecting To Server...");
            yield return e.Current;
        }

cookie = webAsync.requestState.webResponse.Headers["Set-Cookie"];

the code above will check if there is any header named “Set-Cookie” in the response i got from the server.

And code below will set the cookie we found using code above, and set as header for further webRequests.

static void SetBasicRequestData(WebRequest requestToken)
    {
        requestToken.ContentType = "application/x-www-form-urlencoded";
        if (cookie != null)
        {
            requestToken.Headers.Add("Cookie", cookie.ToString());
        }

    }