react-native-cookies
react-native-cookies copied to clipboard
Validate cookie properties in the set method, with more meaningful error messages
According to Apple doc :
To successfully create a cookie, you must provide values for (at least) the NSHTTPCookiePath, NSHTTPCookieName, and NSHTTPCookieValue keys, and either the NSHTTPCookieOriginURL key or the NSHTTPCookieDomain key.
I have therefore added some checks to validate that the provided cookie properties match these requirements. This has the added benefit of allowing the creation of cookies when providing only the required properties.
Also took advantage of promises reject blocks to fail cleanly, with meaningful errors that can be caught directly in JS without crashing the native code.
with this PR, is it possible to set a session-only cookie by not having expiration date?
It will be possible indeed (only for iOS though, I don't know if the Android implementation allows this already).
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.