Shared instance of NSHTTPCookieStorage does not persist cookies

后端 未结 4 1455
-上瘾入骨i
-上瘾入骨i 2021-02-01 07:48

I\'m developing an application where the server hands me a cookie to identify the user.

My successive requests need to have that cookie to have the response that the use

4条回答
  •  无人及你
    2021-02-01 08:30

    humayun might be right -

    However you should not be writing cookies to NSUserDefaults -

    The whole point of the sharedHTTPCookieStorage is you read them from there.

    NSArray *httpCookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:httpUrl];
    

    You should not even be able to write those cookies to NSUserDefaults for security reasons. But maybe you can. Either way its probable that the timeout wasnt set as humayun mentioned.

    Either way please refactor your code and dont try to store cookies in user prefs.

提交回复
热议问题