- NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage]cookiesForURL:[NSURL URLWithString:url]];
- for (NSHTTPCookie *tempCookie in cookies)
- {
-
- NSLog(@"getCookie:%@",tempCookie);
- }
- NSDictionary *Request = [NSHTTPCookie requestHeaderFieldsWithCookies:cookies];
-
- NSUserDefaults *userCookies = [NSUserDefaults standardUserDefaults];
- [userCookies setObject:[Request objectForKey:@"Cookie"] forKey:@"mUserDefaultsCookie"];
- [userCookies synchronize];
再在你須要的頁面中調用出你的cookie,並存放在請求頭中便可xcode
[session.requestSerializer setValue:[[NSUserDefaults standardUserDefaults]objectForKey:@"mUserDefaultsCookie"]forHTTPHeaderField:@"Cookie"]; cookie