Search code examples
iphonenshttpcookie

Clear iPhone simulator cookies


I have an app that makes request to a REST service. Authentication is done using cookies. This already works.

What I have problems with is to test the case when the cookie is no longer valid and my code has to reauthenticate. To test this I have to wait until the cookie is invalid, which could take some time. To accelerate this I figured that if I delete the cookie it would have the same effect.

How to delete all cookies of an app on the iPhone simulator?

I already tried the following:

Deleting <app-dir>/Library/Cookies/Cookies.binarycookies doesn't work. It seems that my cookies are never written to this file.

Deleting all cookies in NSHTTPCookieStorage on app startup doesn't work either.


Solution

  • The cookies are located at:

    /Users/<YourUsername>/Library/Application Support/iPhone Simulator/<iOSversion>/Library/Cookies/Cookies.binarycookies

    You may need to quit out of Safari (in the fast app switching area) and then delete them so Safari won't have them in memory.