Skip to content
pubscout

cookie_jar

4.0.9, released 9 months ago by flutterchina.club

A Dart cookie manager for HTTP requests with in‑memory and persistent storage.

$ flutter pub add cookie_jar
Source repository

What it does

Provides classes to save, load, and delete cookies according to RFC policies. Supports both volatile (CookieJar) and file‑based (PersistCookieJar) storage, and works with HttpClient and dio.

AI-written summary of version 4.0.9, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need automatic cookie handling for HTTP requests
  • You want persistent cookies across app restarts
  • You work with dio or HttpClient and need a simple cookie jar

Skip it when

  • You require a full‑featured HTTP client (use dio or http directly)
  • You need advanced cookie jar features like encryption not provided

Strengths

  • Simple API for saving/loading cookies
  • Supports both in‑memory and file persistence
  • Works on mobile, desktop, and web

Weaknesses

  • Limited to cookie management only, no request/response handling
  • No built‑in encryption or secure storage for cookies

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
2
import 'package:cookie_jar/cookie_jar.dart';

void main() async {
  final jar = CookieJar();
  await jar.saveFromResponse(Uri.parse('https://example.com'), [Cookie('a','1')]);
  final cookies = await jar.loadForRequest(Uri.parse('https://example.com'));
  print(cookies);
}

Alternatives

Packages that do the same job and could replace cookie_jar.

  • dio

    Provides its own interceptor for cookie handling and a full HTTP client

  • http

    Lightweight HTTP client; you can manage cookies manually or with other packages

Works with

Packages commonly used together with cookie_jar: ones it builds on, ones built on it, and its own family.