iosswiftsecuritycookies

How to handle cookies securely during the REST API call in SWIFT 3 or 4?


How can we securely handle the cookies during the API calls? I want the cookies only accessible by the app, not other apps installed on my device. Or can we block to store the cookie's data on my apps? Please suggest or guide me.


Solution

  • Yes, you are right that "Cookies are not shared among applications in iOS.". We also configured the session using ephemeralSessionConfiguration and NSHTTPCookieAcceptPolicyNever before calling the API.

    For your reference : https://developer.apple.com/documentation/foundation/nsurlsessionconfiguration/1410529-ephemeralsessionconfiguration?language=objc https://developer.apple.com/documentation/foundation/nshttpcookieacceptpolicy/nshttpcookieacceptpolicynever?language=objc