Open rsp-84 opened 1 year ago
@rsp-84 Thanks for filing the issue. This issue is reproducible on the latest stable
and master
channels with provided sample code.
✅: No Issue ❌: Issue reproduced
I've just migrated to 4.0.1, and it seems to work fine now. 👌
In version 4.2.0 this issue seems to still be unsolved. I have tried setting cookies with the WebViewCookieManager and it works on Android but fails on iOS.
Same issue, quite severe
Same issue, quite severe
They don't think so ...
Is there any solution yet? I have a similar issue as described by @CRuiz-ObraLink.
When calling WebViewCookieManager.setCookie()
it works fine on android, but on ios the cookies are not set.
I use version 4.7.0
Flutter doctor:
[✓] Flutter (Channel stable, 3.19.1, on macOS 14.2.1 23C71 darwin-arm64, locale en-DE)
• Flutter version 3.19.1 on channel stable at /Users/user/Flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision abb292a07e (5 days ago), 2024-02-20 14:35:05 -0800
• Engine revision 04817c99c9
• Dart version 3.3.0
• DevTools version 2.31.1
[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
• Android SDK at /Users/user/Library/Android/sdk
• Platform android-34, build-tools 34.0.0
• Java binary at: /Users/user/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.15.2
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 2023.1)
• Android Studio at /Users/user/Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
[✓] IntelliJ IDEA Ultimate Edition (version 2023.3.3)
• IntelliJ at /Users/user/Applications/IntelliJ IDEA Ultimate.app
• Flutter plugin version 77.0.1
• Dart plugin version 233.13763.5
[✓] Connected device (3 available)
• iPhone von Entwicklungsteam (mobile) • 00008030-001C1D3C0140C02E • ios • iOS 15.1 19B74
• macOS (desktop) • macos • darwin-arm64 • macOS 14.2.1 23C71 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 122.0.6261.69
[✓] Network resources
• All expected network resources are available.
• No issues fou
```nd!
I have the same issue. Cookies work on Android but not ios. Would really hope for a fix or at least a workaround :)
We ended up using a workaround by passing the cookies inside the headers of the WebViewController.loadRequest as well. That worked for iOS.
We ended up using a workaround by passing the cookies inside the headers of the WebViewController.loadRequest as well. That worked for iOS.
Could you please provide an example? For the life of me I cannot set a cookie on iOS
controller = WebViewController()
..setJavaScriptMode(JavaScriptMode.unrestricted)
..loadRequest(
Uri.parse(
'https://www.myserver.com/myurl'),
headers: {
'Cookie':
'MyCookie=value; Domain=.myserver.com; SameSite=Lax'
});
I am setting a cookies in such a way and it works fine on both Android and iOS:
final WebViewCookie cookie = WebViewCookie(
name: cookieName,
value: cookieValue,
domain: cookieDomain,
);
WebViewCookieManager.fromPlatformCreationParams(const PlatformWebViewCookieManagerCreationParams()).platform.setCookie(cookie);
Packages versions:
webview_flutter: ^4.7.0
webview_flutter_android: ^3.16.0
webview_flutter_wkwebview: ^3.13.0
When setting
initialCookies
on aWebView
with Flutter 3 on an iOS device the cookie(s) are not being applied. It seems to only affect iOS. Android is still working as expected.Steps to Reproduce
Expected results: The test_cookie should be set on both iOS and Android. Currently it is only being set on Android with the
initialCookies:
param onWebView
.Actual results: The test_cookie on iOS is not being set.
Code sample
```dart import 'dart:io'; import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatefulWidget { const MyHomePage({super.key, required this.title}); final String title; @override StateConsole Logs
``` iOS: flutter: Cookie: 1P_JAR=2022-11-16-16; OGPC=19029186-12: Droid: I/flutter (21392): Cookie: "test_cookie=fjklafjdl; 1P_JAR=2022-11-16-16" ```Flutter Doctor
``` [✓] Flutter (Channel unknown, 3.3.8, on macOS 11.7 20G817 darwin-x64, locale en-US) • Flutter version 3.3.8 on channel unknown at /Users/user/Development/flutter • Framework revision 52b3dc25f6 (8 days ago), 2022-11-09 12:09:26 +0800 • Engine revision 857bd6b74c • Dart version 2.18.4 • DevTools version 2.15.0 [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /Users/user/Library/Android/sdk • Platform android-33, build-tools 31.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 13C100 • CocoaPods version 1.11.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2020.3) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7281165) [✓] VS Code (version 1.71.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.52.0 [✓] Connected device (5 available) • Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator) • iPhone 12 (mobile) • 92663F14-DD56-4005-8577-54DD81C5F9AD • ios • com.apple.CoreSimulator.SimRuntime.iOS-15-2 (simulator) [✓] HTTP Host Availability • All required HTTP hosts are available ```