fluttercommunity / fluttercommunity/flutter_webview_plugin
Can I set cookie from outside?
- 主要语言
- Java
- 星标
- 1.5k
- 派生
- 938
- PR 合并指标
- 30 天内没有已合并 PR
描述
## Problem
I see there is a `getCookies` method, but I want to set cookie to webview, so webview and app can share the same session.
I tried the following method, but not working.
```dart
final cookieJar = await vm.config.cookieJar;
final webview = FlutterWebviewPlugin();
for (var item in cookieJar.domains) {
for (var domainCookies in item.values) {
for (var pathCookies in domainCookies.values) {
for (var cookie in pathCookies.values) {
cookie.cookie.httpOnly = false;
print('document.cookie = "${cookie.cookie}";');
await webview.evalJavascript(
'document.cookie = "${cookie.cookie}";');
}
}
}
}
```
I tried the JavaScript code in Chrome, it did work.
## Env
```dart
name: tangbole
description: A tumblr client app.
dependencies:
cookie_jar: ^0.0.4
cupertino_icons: ^0.1.2
english_words: ^3.1.0
dio: ^0.0.14
flutter:
sdk: flutter
flutter_redux: ^0.5.1
flutter_webview_plugin: ^0.1.6
logging: ^0.11.3+1
meta: ^1.1.5
path_provider: ^0.4.1
uri: ^0.11.2
redux: ^3.0.0
redux_logging: ^0.3.0
redux_persist: ^0.7.0-rc.2
redux_persist_flutter: ^0.6.0-rc.1
validate: ^1.6.0
dev_dependencies:
flutter_driver:
sdk: flutter
flutter_test:
sdk: flutter
mockito: ^2.2.3
flutter:
uses-material-design: true
assets:
- images/lake.jpg
```
贡献指南
这个仓库没有索引到贡献指南
调研方向
从公开的 getCookies 和 evalJavascript 入口开始,跟踪 cookieJar 值如何到达原生 WebView。使用 FlutterWebviewPlugin 设置复现报告中的失败;当建立一种受支持的会话 cookie 共享方式,或明确记录不支持该方式时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- dart
- 领域
- mobile-dev
- Issue 类型
- 功能
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 35/100