title: Post request with Cookies in Flutter
body: <p>I'm trying to add Cookies to my request: </p>
  
  <p>Here i get <code>csrftoken</code> with a <code>GET</code> request: </p>
  
  <pre><code> Future&lt;String&gt; getCsrftoken() async{
         var response = await http.get(Uri.encodeFull('http://test/accounts/login/'));
         var csrftoken = response.headers.remove('set-cookie').substring(10,74); //csrf 
         64 chars
         return csrftoken;
      }
  </code></pre>
  
  <p>Here i'm trying to perform the <code>POST</code> (<code>application/x-www-form-urlencoded</code>) request using the package  <a href="https://github.com/flutterchina/dio" rel="nofollow noreferrer">Dio</a>.</p>
  
  <pre><code>getSessionId() async {
    var csrf = await getCsrftoken();
    var cj = new CookieJar();
    List&lt;Cookie&gt; cookies = [new Cookie("csrftoken", csrf)];
    cj.saveFromResponse(Uri.parse("http://test/accounts/login/"), cookies);
    List&lt;Cookie&gt; results = cj.loadForRequest(Uri.parse("http://test/accounts/login/"));
    var dio = new Dio(new Options(
        baseUrl: "http://test/accounts/login/",
        connectTimeout: 5000,
        receiveTimeout: 100000,
        // 5s
        headers: {
        },
        contentType: ContentType.JSON,
        // Transform the response data to a String encoded with UTF8.
        // The default value is [ResponseType.JSON].
        responseType: ResponseType.PLAIN
    ));
  
    Response&lt;String&gt; response;
  
    response = await dio.post("",
      data: {
        "username": "username",
        "password": "password",
        "csrfmiddlewaretoken" : getCsrftoken()
      },
      // Send data with "application/x-www-form-urlencoded" format
      options: new Options(
          contentType: ContentType.parse("application/x-www-form-urlencoded")),
    );
    print(response.statusCode);
  }
  </code></pre>
  
  <p>I get 403 status code, because i need to add as a cookie <code>csrftoken</code>.</p>
  
  <p>How should I proceed?</p>