dio_cookie_manager 2.0.0-beta1 dio_cookie_manager: ^2.0.0-beta1 copied to clipboard
A cookie manager for Dio, which supports persistent cookies in RAM and file.
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();
dio.interceptors.add(CookieManager(cookieJar));
await dio.get("https://baidu.com/");
// Print cookies
print(cookieJar.loadForRequest(Uri.parse("https://baidu.com/")));
// second request with the cookie
await dio.get("https://baidu.com/");
}