ios带cookie进行网络请求

开发评论功能时,需要在cookie中带有token才能发送,网络请求中添加token的方法如下:

NSDictionary *properties = [NSDictionary dictionaryWithObjectsAndKeys:

@"token",NSHTTPCookieValue,               // token值

@"sso_tk", NSHTTPCookieName,            // token名

@"/", NSHTTPCookiePath,                         // 路径

@"域名" ,NSHTTPCookieDomain,           // 域

nil];

NSHTTPCookie *cookie_PD1 = [NSHTTPCookie cookieWithProperties:properties];

[[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie_PD1];

你可能感兴趣的:(ios带cookie进行网络请求)