获取cookie

获取cookie

  //AFNetworing3.0获取cookie
        NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url]];
        for (NSHTTPCookie *tempCookie in cookies)
        {
            //打印cookies
            NSLog(@"getCookie:%@",tempCookie);
        }

        NSDictionary *RequestDic = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies];
        NSLog(@"getCookieDic_______:%@",[RequestDic objectForKey:@"Cookie"]);

        //可以将获取的cookie获取的cookie存入本地,再在你需要的页面中调用出你的cookie,并存放在请求头中即可

你可能感兴趣的:(cookie,url,ios小知识)