fryette / webview_cookie_manager

MIT License
48 stars 52 forks source link

Exposes the Expires attribute on Android to flutter apps, aligning with iOS. #26

Closed negator closed 3 years ago

negator commented 3 years ago

Exposes the Expires attribute on Android to flutter apps, aligning with iOS.

The HttpCookie class in Android (java.net sdk) has awkward Expires handling. It translates Expires into Max-Age by first converting it into a seconds offset from the current system time as described here: https://www.mit.edu/afs.new/sipb/project/android/docs/reference/java/net/HttpCookie.html. And as a consequence Expires is not available from an accessor, it must be calculated from the Max-Age attribute by performing the reverse translation. This patch performs that translation to ensure we carry over the remaining the duration between cookie gets and sets, aswell as to align with iOS which does expose Expires.

It should be noted that Expires is a deprecated attributed, in favor of the newer Max-Age attribute. However due to the nature of how this is handled on Android, namely that max-age is not readjusted and thus cannot be used reliably between getting and setting of cookies, we should use Expires to ensure cookies expire properly.

fryette commented 3 years ago

Will check on a few projects and merge it. Please wait a couple of hours/days

Thanks for your contribution!