Reputation: 335
I'm fairly new to React Native and Expo, and I'm confused about how cookies are managed. I have an Express server that sets a token cookie in a response (res.cookie("jwt",token)
). Somehow when my React Native client makes an authentication request and receives a response, the client stores the cookie somewhere, and the token is passed in future requests (with credentials: "include"
), until I restart the emulator. My main questions are
Thank you in advanced for your help!
Upvotes: 2
Views: 16140
Reputation: 469
ReactNative does not have this support by default as it runs on the native side (well, you do have support on the WebView component but that's isolated)
If you are relying on Expo they are still figuring out the cookies management, you can follow the updates in this issue, they are aware about the persistence of cookies been inconsistent between app loads:
https://github.com/expo/expo/issues/6756
If you have to use the cookies anyway I would suggest to use this lib, it seems quite stable, but maybe you will need to implement some integrations with your API yourself:
https://github.com/react-native-cookies/cookies
Wish success on your project.
Upvotes: 6