你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> iOS 帶cookie進行網絡請求

iOS 帶cookie進行網絡請求

編輯:IOS開發綜合

  開發評論功能時,需要在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];

 

 

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved