Skip to content
This repository has been archived by the owner on Jan 13, 2020. It is now read-only.

CookieManager.set returns undefined #14

Open
edo1493 opened this issue Jan 2, 2020 · 7 comments
Open

CookieManager.set returns undefined #14

edo1493 opened this issue Jan 2, 2020 · 7 comments
Labels
bug Something isn't working

Comments

@edo1493
Copy link

edo1493 commented Jan 2, 2020

Hey guys,

I was trying to set a cookie, but it's always returning undefined, which is due to https://github.com/safaiyeh/react-native-cookie-store/blob/master/ios/RNCookieManagerIOS/RNCookieManagerIOS.m#L69.

I have tried to call getAll instead, but I can't see it. Is there a way to figure out if this has been set or not? Thanks and sorry for the generic question.

There is also this that might be removed https://github.com/safaiyeh/react-native-cookie-store/blob/master/ios/RNCookieManagerIOS/RNCookieManagerIOS.m#L54.

@safaiyeh
Copy link
Owner

safaiyeh commented Jan 2, 2020

Hey @edo1493! Thanks for the issue.

Could you provide a code snippet for what you are trying to achieve?

@safaiyeh safaiyeh added the bug Something isn't working label Jan 3, 2020
@edo1493
Copy link
Author

edo1493 commented Jan 3, 2020

Hi @safaiyeh, I am just trying to set a cookie and trying to see if this was set. :)

I was trying with getAll, but couldn't see anything, and double checked via Safari dev tools.

Would this work?

CookieManager.set({
  name: 'myCookie',
  value: 'myValue',
  domain: 'some domain',
  origin: 'some origin',
  path: '/',
  version: '1',
  expiration: '2015-05-30T12:30:00.00-05:00'
}).then((res) => {
  console.log('CookieManager.set =>', res);
});

@safaiyeh
Copy link
Owner

safaiyeh commented Jan 3, 2020

It is a known issue that get and getAll are not working correctly.

It currently works if you pass true for webKit.

This issue has a couple work arounds for you to try
joeferraro/react-native-cookies#152

@safaiyeh safaiyeh closed this as completed Jan 3, 2020
@safaiyeh safaiyeh reopened this Jan 3, 2020
@safaiyeh
Copy link
Owner

safaiyeh commented Jan 3, 2020

Action items from this:

set & get & getAll needs to work without webkit enabled.

@safaiyeh
Copy link
Owner

safaiyeh commented Jan 3, 2020

Also @edo1493 I'll happily take a PR with NSLog's deleted :)

@safaiyeh
Copy link
Owner

safaiyeh commented Jan 3, 2020

this currently works for me @edo1493

  CookieManager.set({
    name: 'myCookie',
    value: 'myValue',
    domain: 'example.com',
    origin: '/',
    path: '/',
    version: '1',
    expiration: '2015-05-30T12:30:00.00-05:00'
  }, true).then((res) => {
    CookieManager.getAll(true).then((res) => {
      console.log(res);
    })
  });

Screen Shot 2020-01-03 at 3 26 43 PM

@edo1493
Copy link
Author

edo1493 commented Jan 8, 2020

Hi @safaiyeh, thanks for pointing it out. I am going to double check. :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants