NSHTTPCookies refuse to be deleted

后端 未结 3 1286
长发绾君心
长发绾君心 2020-12-16 04:48

I need a log out button for my app, I have the below code:

        while ([[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies] count] != 0) {
                    


        
3条回答
  •  北海茫月
    2020-12-16 05:12

    The problem seems to be that the cookies are cached and not saved out to a file immediately.

    I made a sample project to reproduce this issue — and found that it would only occur when the app receives a SIGKILL signal, like when the debugger is stopped from within Xcode. In my experiments, unhandled exceptions, crashes, exit() and abort() don't cause NSHTPPCookieStorage to loose data.

    As this looks like a debugging-only issue (it only occurs when using the debugger), I closed the radar I filled previously.

    I couldn't test everything though: feel free to use the sample project to see if other source of crashes could trigger a cookies loss.

提交回复
热议问题