Skip to content
Branch: master
Find file History
Almoullim Correct import path
Correct import path for dio_cookie_manager in the Usage section
Latest commit b8b6e17 Sep 20, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
example update to 3.0 Sep 18, 2019
lib update doc Sep 17, 2019
test update doc Sep 17, 2019
.gitignore 1. Support Flutter Web Sep 17, 2019
.metadata 1. Support Flutter Web Sep 17, 2019 update to 3.0 Sep 18, 2019
LICENSE 1. Support Flutter Web Sep 17, 2019 Correct import path Sep 20, 2019
pubspec.yaml update to 3.0 Sep 18, 2019

dio_cookie_manager Pub

A cookie manager for Dio.

Getting Started


  dio_cookie_manager: 1.0.x  #latest version


import 'package:dio/dio.dart';
import 'package:dio_cookie_manager/dio_cookie_manager.dart';
import 'package:cookie_jar/cookie_jar.dart';

main() async {
  var dio =  Dio();
  var cookieJar=CookieJar();
  // Print cookies
  // second request with the cookie
  await dio.get("");

Cookie Manager

CookieManager Interceptor can help us manage the request/response cookies automaticly. CookieManager depends on cookieJar package :

The dio_cookie_manager manage API is based on the withdrawn cookie_jar.

You can create a CookieJar or PersistCookieJar to manage cookies automatically, and dio use the CookieJar by default, which saves the cookies in RAM. If you want to persists cookies, you can use the PersistCookieJar class, for example:


PersistCookieJar persists the cookies in files, so if the application exit, the cookies always exist unless call delete explicitly.

Note: In flutter, the path passed to PersistCookieJar must be valid(exists in phones and with write access). you can use path_provider package to get right path.

In flutter:

Directory appDocDir = await getApplicationDocumentsDirectory();
String appDocPath = appDocDir.path;
var cookieJar=PersistCookieJar(dir:appdocPath+"/.cookies/");
You can’t perform that action at this time.