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.
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.
Works with
Packages commonly used together with cookie_jar: ones it builds on, ones built on it, and its own family.
- universal_iocookie_jar depends on itCross-platform dart:io implementation with browser support for HttpClient and other APIs
- dio_cookie_managerBuilt on cookie_jarA cookie manager for Dio combining cookie_jar and Dio based on the interceptor algorithm.
- appwriteBuilt on cookie_jarFlutter SDK for the self-hosted Appwrite backend server
- flutter_better_authBuilt on cookie_jarDart and Flutter client for the Better Auth platform.
- better_auth_flutterBuilt on cookie_jarFlutter SDK for Better Auth providing email/password, social sign‑in, session management and reactive auth state.