本文介绍了UIWebView 的 cookie 存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个带有 cookie 的 iPhone 应用程序.在 Safari 设置中删除 cookie 不会删除它们.它们存放在哪里?是否可以从另一个 UIWebView 读取它们?

I'm building an iPhone app with cookies. Deleting cookies in the Safari settings doesn't delete them. Where are they stored? Is it possible to read them from another UIWebView?

谢谢!

推荐答案

您的应用程序在 [NSHTTPCookieStorage sharedHTTPCookieStorage] 容器中有自己的cookie jar".

Your application has its own "cookie jar" in the [NSHTTPCookieStorage sharedHTTPCookieStorage] container.

您可以通过以下方式快速查看应用程序的 cookie jar 中的 cookie:

Here's how you might take a quick look at the cookies in your application's cookie jar:

NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [cookieJar cookies]) {
   NSLog(@"%@", cookie);
}

有多种方法可用于过滤和操作.查看 NSHTTPCookieStorage 文档用于访问 cookie,以及 NSHTTPCookie用于访问单个 cookie 属性的文档.

Several methods are available for filtering and manipulation. Take a look at the NSHTTPCookieStorage documentation for accessing cookies, and the NSHTTPCookie documentation for accessing individual cookie properties.

这篇关于UIWebView 的 cookie 存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-30 09:30