dev-yakuza / dev-yakuza.github.io

8 stars 9 forks source link

[Flutter] How to use cookie with webview_flutter - Let's see how to use cookie in the webview that is shown by webview_flutter on Flutter. #83

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

[Flutter] How to use cookie with webview_flutter - Let's see how to use cookie in the webview that is shown by webview_flutter on Flutter.

Let's see how to use cookie in the webview that is shown by webview_flutter on Flutter.

https://dev-yakuza.posstree.com/en/flutter/webview_flutter/cookie/

gugadev commented 1 year ago

What about adding max-age or expires attributes to the cookie using WebCookieManager#setCookie? 🤔

dev-yakuza commented 1 year ago

@gugadev WebCookieManager does not provide arguments and parameters about the max-age(expires).

So, I think you need to manage the cookies by yourself. I mean you store the max-age info in shared_preferences and check it every time to delete them.

gugadev commented 1 year ago

It looks like you need to pass the arguments in the value argument too, according to the RFC. For example:

WebViewCookie(
  name: "my-cookie",
  value: "$cookieValue;max-age=30000;",
  domain: "acme.com",
);
dev-yakuza commented 1 year ago

@gugadev Thanks for sharing the info.

I see the comments in the code.

  /// The cookie-value of the cookie.
  ///
  /// Its value should match "cookie-value" in RFC6265bis:
  /// https://datatracker.ietf.org/doc/html/draft-ietf-httpbis-rfc6265bis-02#section-4.1.1
  final String value;

So, your solution is correct, I think.