Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie manager for flutter web #585

Closed
developerandre opened this issue Dec 1, 2019 · 6 comments
Closed

Cookie manager for flutter web #585

developerandre opened this issue Dec 1, 2019 · 6 comments

Comments

@developerandre
Copy link

Do you plan for support Cookie manager in web?

@wendux
Copy link
Contributor

wendux commented Dec 2, 2019

No, cookies are automatically managed by the browser

@wendux wendux closed this as completed Dec 2, 2019
@Charliego3
Copy link

No, cookies are automatically managed by the browser

Use flutter web to develop websites, and background services use golang, but cookies cannot always be set automatically when I request an interface. The headers returned by dio printing in flutter are only Content-Type and Content-Length, but in the browser developer mode, There is a Set-Cookie option in the Response header. The cookie-manager with the dio plug-in also has no effect. How to solve this situation?

image
image
image

@Charliego3
Copy link

I solved this problem.

BaseOptions options = new BaseOptions(
    baseUrl: _baseUrl,
    connectTimeout: 10000,
    receiveTimeout: 5000,
    headers: {
        "Accept": "application/json",
    },
);
DioForBrowser _d = DioForBrowser(options);
var adapter = BrowserHttpClientAdapter();
// This property will automatically set cookies
adapter.withCredentials = true;
_d.httpClientAdapter = adapter;
_d.get("http://localhost:1234/login...")

@chitgoks
Copy link

My original comment was it did not work but i was mistaken. It does. the thing is, withCredentials is required in order for cookies to be written to browser.

Shouldnt the default dio object have this property? instead of having to use DioForBrowser?

@LucaIaconelli
Copy link

I solved this problem.

BaseOptions options = new BaseOptions(
    baseUrl: _baseUrl,
    connectTimeout: 10000,
    receiveTimeout: 5000,
    headers: {
        "Accept": "application/json",
    },
);
DioForBrowser _d = DioForBrowser(options);
var adapter = BrowserHttpClientAdapter();
// This property will automatically set cookies
adapter.withCredentials = true;
_d.httpClientAdapter = adapter;
_d.get("http://localhost:1234/login...")

Hello,

I performed this procedure but flutter continues to print as content-type headers only: application/json; charset = utf-8 and not all data present in the console. How can I solve it?

Thanks in advance

@tstrg
Copy link

tstrg commented Aug 29, 2020

I'm still not able to see the cookie in chrome tab

I solved this problem.

BaseOptions options = new BaseOptions(
    baseUrl: _baseUrl,
    connectTimeout: 10000,
    receiveTimeout: 5000,
    headers: {
        "Accept": "application/json",
    },
);
DioForBrowser _d = DioForBrowser(options);
var adapter = BrowserHttpClientAdapter();
// This property will automatically set cookies
adapter.withCredentials = true;
_d.httpClientAdapter = adapter;
_d.get("http://localhost:1234/login...")

Hello,

I performed this procedure but flutter continues to print as content-type headers only: application/json; charset = utf-8 and not all data present in the console. How can I solve it?

Thanks in advance

I'm facing the same issue. I set the withCredentials to true, but I'm still not able to see the cookies in the chrome dev tab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants