CookieHandler

The CookieHandler adds cookie support to your pipeline - cookies in your CookieContainer are sent with each request, and cookies set by the server are populated back into the CookieContainer for you.

To use it simply call the UseCookieHandler() extension method:

var config = new Config()
                  .UseCookieHandler();

dynamic client = new RestClient("https://httpbin.org", config);

var result = await client.Cookies.Set.Query(new { foo = "bar" }).Get();

If you want control of the cookies pass your own CookieContainer:

var cookieContainer = new CookieContainer();
cookieContainer.Add(new Uri("https://httpbin.org"), new Cookie("foo", "bar"));

var config = new Config()
                  .UseCookieHandler(cookieContainer);

dynamic client = new RestClient("https://httpbin.org", config);

var result = await client.Cookies.Get();

You can get the CookieContainer from the response using the GetCookieContainer() extension method on HttpResponseMessage.

When using IHttpClientFactory use the UseCookieHandler extension method when adding the RestClient to your .NET Core DI container (usually in Startup.cs):

services
      .AddRestClient("https://httpbin.org")
      .UseCookieHandler(cookieContainer);

Updated: