react-native-cookies / cookies

🍪 Cookie Manager for React Native
MIT License
482 stars 95 forks source link

How to set multiple cookies pair from the response header #110

Open ashok13ask opened 3 years ago

ashok13ask commented 3 years ago

My reponse header includes access token, refresh token and some other flags as a cookie set, but when i try to set cookies using setFromResponse method, it's just saving the first cookie only

My Reponse cookies

access_token_cookie=eyJ0eXAiOiJKV1QiLCJ; Expires=Sun, 04-Apr-2021 12:54:59 GMT; Max-Age=3154; HttpOnly; Path=/; SameSite=None, csrf_access_token=8ee44170; Expires=Sun, 04-Apr-2021 12:54:59 GMT; Max-Age=31540; Path=/; SameSite=None, refresh_token_cookie=eyJ0; Expires=Sun, 04-Apr-2021 12:54:59 GMT; Max-Age=31540; HttpOnly; Path=/token/refresh; SameSite=None, csrf_refresh_token=351ede70-ab4d-; Expires=Sun, 04-Apr-2021 12:54:59 GMT; Max-Age=3154; Path=/; SameSite=None, logged_in=true; Path=/; SameSite=None, session=eyJ1cmwiOiIMOMjyTd150Pj3L5v0; Path=/; SameSite=None

But in my application only first cookie is stored

gmyuqi commented 3 years ago

same

hyojun-parkk commented 1 year ago

Hello Did you solve this problem?

kevinvangelder commented 6 days ago

This also seems to be happening in my project. Has anyone found a workaround?

In theory, if you were able to manually grab your Set-Cookies response header, split it into individual cookies, and pass each one individually to CookieManager.setFromResponse you might be able to work around the problem.

From docs:

CookieManager.setFromResponse(
  'http://example.com',
  'user_session=abcdefg; path=/; expires=Thu, 1 Jan 2030 00:00:00 -0000; secure; HttpOnly')
    .then((success) => {
      console.log('CookieManager.setFromResponse =>', success);
    });