UI WebView의 쿠키는 어디에 저장됩니까?
저는 쿠키로 아이폰 앱을 만들고 있습니다.Safari 설정에서 쿠키를 삭제해도 삭제되지 않습니다.그것들은 어디에 보관됩니까?다른 UI WebView에서 읽을 수 있습니까?
감사합니다!
프로그램에 자체 "쿠키 병"이 있습니다.[NSHTTPCookieStorage sharedHTTPCookieStorage]
컨테이너.
다음은 프로그램의 쿠키 상자에 있는 쿠키를 간단히 살펴볼 수 있는 방법입니다.
NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [cookieJar cookies]) {
NSLog(@"%@", cookie);
}
필터링 및 조작에는 몇 가지 방법을 사용할 수 있습니다.쿠키에 액세스하는 방법은 NSHTT 쿠키 저장소 문서를 참조하고 개별 쿠키 속성에 액세스하는 방법은 NSHTT 쿠키 문서를 참조하십시오.
알렉스 포인터 고마워요!여기에 추가하기 위해 알렉스의 예를 사용하여 만든 "쿠키 덤프"를 넣겠습니다.아마도 이것은 다른 누군가에게 도움이 될 것입니다.
- (void) dumpCookies:(NSString *)msgOrNil {
NSMutableString *cookieDescs = [[[NSMutableString alloc] init] autorelease];
NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [cookieJar cookies]) {
[cookieDescs appendString:[self cookieDescription:cookie]];
}
NSLog(@"------ [Cookie Dump: %@] ---------\n%@", msgOrNil, cookieDescs);
NSLog(@"----------------------------------");
}
- (NSString *) cookieDescription:(NSHTTPCookie *)cookie {
NSMutableString *cDesc = [[[NSMutableString alloc] init] autorelease];
[cDesc appendString:@"[NSHTTPCookie]\n"];
[cDesc appendFormat:@" name = %@\n", [[cookie name] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[cDesc appendFormat:@" value = %@\n", [[cookie value] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
[cDesc appendFormat:@" domain = %@\n", [cookie domain]];
[cDesc appendFormat:@" path = %@\n", [cookie path]];
[cDesc appendFormat:@" expiresDate = %@\n", [cookie expiresDate]];
[cDesc appendFormat:@" sessionOnly = %d\n", [cookie isSessionOnly]];
[cDesc appendFormat:@" secure = %d\n", [cookie isSecure]];
[cDesc appendFormat:@" comment = %@\n", [cookie comment]];
[cDesc appendFormat:@" commentURL = %@\n", [cookie commentURL]];
[cDesc appendFormat:@" version = %d\n", [cookie version]];
// [cDesc appendFormat:@" portList = %@\n", [cookie portList]];
// [cDesc appendFormat:@" properties = %@\n", [cookie properties]];
return cDesc;
}
알렉스는 이것을 범주에 넣는 것에 대해 좋은 아이디어를 가지고 있었습니다.사용하게 된 내용은 다음과 같습니다.
NSHTT PookieStorage+Info.h
#import <Foundation/Foundation.h>
@interface NSHTTPCookieStorage (Info)
+ (NSDictionary*) describeCookies;
+ (NSDictionary *) describeCookie:(NSHTTPCookie *)cookie;
@end
NSHTTP 쿠키 저장소.m.
@implementation NSHTTPCookieStorage (Info)
+ (NSDictionary*) describeCookies {
NSMutableDictionary *descriptions = [NSMutableDictionary new];
[[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies] enumerateObjectsUsingBlock:^(NSHTTPCookie* obj, NSUInteger idx, BOOL *stop) {
[descriptions setObject:[[self class] describeCookie:obj] forKey:[[obj name] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
}];
NSLog(@"Cookies:\n\n%@", descriptions);
return descriptions;
}
+ (NSDictionary *) describeCookie:(NSHTTPCookie *)cookie {
return @{@"value" : [[cookie value] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding],
@"domain" : [cookie domain] ? [cookie domain] : @"n/a",
@"path" : [cookie path] ? [cookie path] : @"n/a",
@"expiresDate" : [cookie expiresDate] ? [cookie expiresDate] : @"n/a",
@"sessionOnly" : [cookie isSessionOnly] ? @1 : @0,
@"secure" : [cookie isSecure] ? @1 : @0,
@"comment" : [cookie comment] ? [cookie comment] : @"n/a",
@"commentURL" : [cookie commentURL] ? [cookie commentURL] : @"n/a",
@"version" : @([cookie version]) };
}
@end
출력을 조금 더 "JSON-y"로 만듭니다.
에sandbox:Library->Cookies->Cookies.binarycookies
하지만 당신은 열 수 없습니다..binarycookie
직접 스크립트를 실행할 수 있습니다.
Python 다운로드 및 설치
BinaryCookieReader.py 다운로드
터미널에서 "Python BinaryCookieReader.py "을 실행합니다.
보시다시피 출력 로그에는 쿠키에 대한 자세한 설명이 포함되어 있습니다.
언급URL : https://stackoverflow.com/questions/771498/where-are-an-uiwebviews-cookies-stored
'sourcecode' 카테고리의 다른 글
별도의 개발 및 Prod Firebase 환경 (0) | 2023.08.12 |
---|---|
UI WebView에서 WKWebView로 마이그레이션 (0) | 2023.08.12 |
PM2의 클러스터 및 포크 모드 차이 (0) | 2023.08.12 |
SQL Server 2005: 트리거를 일시적으로 비활성화하는 T-SQL (0) | 2023.08.12 |
파일 생성 날짜 범위로 Powershell Get-Child 항목 제한 (0) | 2023.08.07 |