webview_cookie_manager 패키지는 Android 및 iOS의 웹뷰를 사용하는 Flutter 앱을 위한 포괄적인 쿠키 관리를 제공합니다. 웹뷰에서 렌더링된 웹 콘텐츠와 관련된 쿠키를 읽고, 쓰고, 삭제하고, 관리할 수 있게 해주며, 세션 처리와 인증을 원활하게 보장합니다. 이 패키지는 플랫폼별 웹뷰 구현과 직접 작동하도록 설계되어 플랫폼 간 일관된 API를 제공합니다. 지속적인 로그인 상태 또는 웹 기반 서비스와의 통합이 필요한 앱에 이상적입니다.
사용 사례
웹뷰에서 인증 세션 관리
앱 재시작 후 사용자 로그인 상태 유지
WebView와 백엔드 서비스 간의 쿠키 동기화
OAuth와 같은 제3자 로그인 흐름 처리
저장된 쿠키를 사용한 폼 제출 자동화
주요 기능
Android 및 iOS용 크로스 플랫폼 쿠키 관리
웹뷰에서 쿠키 읽기 및 쓰기 지원
플랫폼 웹뷰 컴포넌트와의 통합
일반적인 쿠키 작업을 위한 간단한 API
쿠키 데이터의 안전한 저장
적합한 대상
임베드된 웹 콘텐츠를 가진 앱
인증 집약형 애플리케이션
웹 서비스 통합
단일 로그인 (SSO) 워크플로
웹 기반 백엔드를 사용하는 모바일 앱
고려 사항
웹뷰 액세스를 위해 적절한 권한이 필요합니다
웹뷰 전용 쿠키 컨텍스트에 한정
복잡한 시나리오를 위해 추가 설정이 필요할 수 있습니다
일반적인 앱 전체 쿠키 관리에 적합하지 않습니다
기반 플랫폼의 웹뷰 구현에 따라 다름
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
Webview Cookie Manager
A flutter library to manager your web cookies for Android (API level 9+) and iOS (11+).
The WebCookieManager can be used directly or together with webview_flutter.
Get cookies
final cookieManager = WebviewCookieManager();
final gotCookies = await cookieManager.getCookies('https://youtube.com');
for (var item in gotCookies) {
print(item);
}
Domain attribute is not required according to RFC, but it is important to remember that empty domain causes undefined behavior. So it is highly reccommended to specify it this this way:
final cookie = Cookie('cookieName', 'cookieValue')..domain = 'youtube.com';
Secure attribute
If you see the error Strict Secure Cookie policy does not allow setting a secure cookie for http://your-domain.net/ for apps targeting >= R. Please either use the 'https:' scheme for this URL or omit the 'Secure' directive in the cookie value. Then you need to set the origin while setting the cookie, in that case setting the domain is not required.
final cookies = <Cookie>[];
// Add your cookie with secure flag to the array
cookieManager.setCookies(cookies, origin: 'https://your-domain.net')
Troubleshooting on iOS
Set minimum target iOS version to 11 (see also #17)
If you are using Objective C, check that PodFile have a flag use_frameworks (see also #4)
target 'Runner'do
use_frameworks!
use_modular_headers!
..........
end