NSMutableArray *cookiesStoreAll = [[NSMutableArray alloc]init];
 NSUInteger totalNumberOfCookies;    
 NSMutableURLRequest *request_get = [[[NSMutableURLRequest alloc] init] autorelease]; 
 [request_get setURL:[NSURL URLWithString:urlStr]]; 
 [request_get setHTTPMethod:@"GET"];
 [request_get setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"]; 
 [request_get setHTTPShouldHandleCookies:YES]; 
 // doGet - response 
 
 NSHTTPURLResponse *response_get = nil;  
 NSError *error_get = nil; 
 NSData *responseData_get = [NSURLConnection sendSynchronousRequest:request_get returningResponse:&response_get error:&error_get]; 
 NSString *data_get=[[NSString alloc]initWithData:responseData_get encoding:NSUTF8StringEncoding];   
 //get the cookies by using the header cookies  
  [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways]; 
 NSDictionary *headerFields_get = [(NSHTTPURLResponse*)response_get allHeaderFields]; 
 NSURL *urlCookies_get = [NSURL URLWithString:urlStr]; 
 NSArray *cookies_get = [NSHTTPCookie cookiesWithResponseHeaderFields:headerFields_get forURL:urlCookies_get];    
// retrieve the cookies from url by sharedHTTPCookieStore 
 NSArray *cookiesUse_get = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:urlCookies_get];
 NSUInteger numberOfCookiesUse_get = [cookiesUse_get count];  
 NSUInteger numberOfCookies_get = [cookies_get count];
 NSLog(@"numberOfCookies_get==:%d", numberOfCookies_get);
 
 for (NSHTTPCookie *cookie in cookies_get) {
  NSLog(@"numberOfCookies_get :Name: %@ : Value: %@", cookie.name, cookie.value);
 }
 
 NSLog(@"numberOfCookiesUse_get==:%d", numberOfCookiesUse_get);
 
 for (NSHTTPCookie *cookie in cookiesUse_get) {
  NSLog(@"numberOfCookiesUse_get :Name: %@ : Value: %@", cookie.name, cookie.value);
 }
 
 // Cookie - add the array to the cookieStoreAll 
 [cookiesStoreAll addObjectsFromArray: cookiesUse_get]; 
 totalNumberOfCookies = [cookiesStoreAll count];   
 //NSString *realCookieValue;   
 // get the needed cookie and convent to the NSString  
 for(int j=0; j<totalNumberOfCookies; j++)  {   
  NSLog(@"numberOfCookiesUse_get==:%@", [[cookiesStoreAll objectAtIndex:j] name]);
  NSLog(@"numberOfCookiesUse_get==:%@",[[cookiesStoreAll objectAtIndex:j] value]);
  //NSString *realCookieName = [[cookiesStoreAll objectAtIndex:j] name];     
  //if([realCookieName isEqualToString: @"neededCookieName"])     
  //{         
   //realCookieValue = [[cookiesStoreAll objectAtIndex:j] value];         
   //cookiesString = [NSString stringWithFormat:@"neededCookieName=%@; ", realCookieValue];     
  //}  
 }

cookie 内容的获取的更多相关文章

  1. C++ 与 php 的交互 之----- C++ 获取 网页文字内容,获取 php 的 echo 值。

    转载请声明出处! http://www.cnblogs.com/linguanh/category/633252.html 距离上次 谈 C++ 制作json 或者其他数据传送给 服务器,时隔两个多月 ...

  2. 内容页获取当前栏目的上一级栏目ID

    发现V9在列表页可以用$parentid 得到当前栏目的父级ID,但在内容页这个函数的值却为空了,需要按下面的写法才行, V9 在内容页获取当前栏目的上一级栏目ID {$CAT[parentid]} ...

  3. cookie——创建、获取、删除

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. C#中在内容页获取其模板页中的变量,或者值

    在CSDN的博文中看到了 muziduoxi 的文章:http://blog.csdn.net/muziduoxi/article/details/5386543 虽然里面提到的方法没有解决我的难题, ...

  5. Servlet实现禁用cookie重写URL获取session

    前言 一个女人让他的程序员丈夫去商店买东西:你去附近的商店买些鸡蛋,如果有香蕉的话,买8个回来,这个丈夫买了8个鸡蛋回来,他的妻子大吃一惊:你为什么买了8个鸡蛋?! 程序员丈夫回答:因为他们有香蕉. ...

  6. 关于MFC文本框输入内容的获取 与 设置文本框的内容

    八月要开始做界面了<( ̄︶ ̄)/,然而目前只会用MFC╮(╯▽╰)╭ 好吧,言归正传,设置好文本框后,要获取用户输入的内容,可以用: GetDlgItemText() ; 这个函数有两个参数,第 ...

  7. javascript获取iframe框架中页面document对象,获取子页面里面的内容,iframe获取父页面的元素,

    javascript获取iframe框架中,加载的页面document对象 因为浏览器安全限制,对跨域访问的页面,其document对象无法读取.设置属性 function getDocument(i ...

  8. [转]javascript js cookie的存储,获取和删除

    本文转自:http://www.jb51.net/article/13240.htm 使用方法: //1.存储Cookie //2.参数说明: 1.参数1:Cookie存储Name,参数2:Cooki ...

  9. Android初级教程之内容提供者获取联系人信息

    内容提供折详细理论知识请参考之前的博文:http://blog.csdn.net/qq_32059827/article/details/51646513 这里新建了三个联系人信息,通过查看系统联系人 ...

随机推荐

  1. 5.3.2 Eclipse集成开发环境的使用技巧

    Eclipse具有强大的编辑.调试.编译和打包功能,本节仅讲解Eclipse中最常用的功能. 1.将程序代码和注释字体变大 (1)启动Eclipse,选择“Windows”->“Preferen ...

  2. centos7 学习

    1.centos pid文件: 在Linux系统的目录/var/run下面一般我们都会看到很多的*.pid文件.而且往往新安装的程序在运行后也会在/var/run目录下面产生自己的pid文件.那么这些 ...

  3. Qt之QRadioButton

    简述 QRadioButton部件提供了一个带有文本标签的单选框(单选按钮). QRadioButton是一个可以切换选中(checked)或未选中(unchecked)状态的选项按钮.单选框通常呈现 ...

  4. hdu 4081 Qin Shi Huang's National Road System (次小生成树)

    Qin Shi Huang's National Road System Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/3 ...

  5. Subsets [LeetCode]

    Given a set of distinct integers, S, return all possible subsets. Note: Elements in a subset must be ...

  6. AppSettings和ConnectionStrings的区别

    AppSettings是ASP.NET1.1时期用的,在.NET Framework 2.0中,新增了ConnectionStrings. 1.<connectionStrings> &l ...

  7. java arrayCopy

    int[] dest = new int[0]; int[] value = {1,2}; if(value != null && value.length>0) { int[] ...

  8. A-Making the Grade(POJ 3666)

    Making the Grade Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4656   Accepted: 2206 ...

  9. MySQL的information_schema的介绍

    information_schema数据库是MySQL自带的,它提供了访问数据库元数据的方式.什么是元数据呢?元数据是关于数据的数据,如数据库名或表名,列的数据类型,或访问权限等.有些时候用于表述该信 ...

  10. Python的神奇方法指南

    参考:http://article.yeeyan.org/view/311527/287706