flutterchina/cookie_jar

Default cookie jar should not use static storage for cookies

wstrange opened this issue · 3 comments

It took me a while to figure this out, but the default Cookie Jar uses a static list of cookies. Two instances of the CookieJar will reuse the same memory, which is really surprising and unexpected behavior.

In my case, I have two test dio clients where I do not want to share cookies between the two clients.

consumers of cookieJar can always create a single instance if they really want a single global cookie store.

I'm happy to send a PR to fix this.

The easiest solution is to just delete the static from https://github.com/flutterchina/cookie_jar/blob/master/lib/src/default_cookie_jar.dart#L20

A PR that drops static might be a breaking change - so I could bump the semver if that works. I suppose another option is to add a new constructor CookieJar.newInstance()?

Thoughts?

I think the best long term approach is to let the library consumer handle creating static instances (if that is what they really want...), but that would possibly break some existing clients that depend on the static behaviour.

It is fixed in 3.0.0-beta2.