IOS - 打印COOKIE

?NSHTTPCookie

在iOS中使用NSHTTPCookie类封装一条cookie,通过NSHTTPCookie的方法读取到cookie的通用属性。

- (NSUInteger)version; 
- (NSString *)name;
- (NSString *)value;
- (NSString *)domain; 
- (NSString *)path;
- (BOOL)isSessionOnly;
现在,我们需要读取cookie字段中的CRFS-TOKEN字段,

NSHTTPCookieStorage *cookie=[NSHTTPCookieStoragesharedHTTPCookieStorage];

for (NSHTTPCookie *cookieitem in? [cookie cookies]) {

? ? ? NSLog(@"COOKIE PATH :: %@",cookieitem.path);

? ? ? NSLog(@"COOKIE VERSION :: %d",cookieitem.version);

? ? ? NSLog(@"COOKIE DOMAIN :: %@",cookieitem.domain);

? ? ? NSLog(@"COOKIE NAME :: %@",cookieitem.name);

? ? ? NSLog(@"COOKIE VALUE :: %@",cookieitem.value);

? ? ? NSLog(@"COOKIE ISSESSIONONLY ::%d",cookieitem.isSessionOnly);

}

查看运行结果:

IOS - 打印COOKIE

这样我们就可以读取cookie中的字段值。

IOS - 打印COOKIE,布布扣,bubuko.com

IOS - 打印COOKIE

上一篇:iOS面试题之加载单张图片到底会不会崩溃?


下一篇:iOS 开发之 - iOS6 适配, UITextField 文本,placeholder没有居中对齐