joeferraro / react-native-cookies

Cookie manager for React Native
MIT License
788 stars 315 forks source link

 【Android】setFromResponse method is not working v3.3.0 #134

Open NaoyaKurahashi opened 5 years ago

NaoyaKurahashi commented 5 years ago

We can't set cookies using setFromResponse method...

CookieManager.setFromResponse(
  'http://example.com', 
  'user_session=abcdefg; path=/; expires=Thu, 1 Jan 2030 00:00:00 -0000; secure; HttpOnly')
    .then((res) => {
      // `res` will be true or false depending on success.
      console.log('CookieManager.setFromResponse =>', res);
    });

In this code pass string cookie props to setFromResponse, but we can't set some cookies at once.

The reason why, in CookieManagerModule.java convert string cookies to string List, but converting List seems not working well.

If we will set some cookies...

we must call setFromResponse method  some times same as cookies length.

This code work.

CookieManager.setFromResponse(
  'http://example.com', 
  'user_session=abcdefg;')
    .then((res) => {
      // `res` will be true or false depending on success.
      console.log('CookieManager.setFromResponse =>', res);
    });
safaiyeh commented 4 years ago

I have forked the repo here: https://github.com/safaiyeh/react-native-cookie-store We can create issues and PRs there to continue the development of the project.