当前位置:编程学习 > wap >>

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 ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,