WKWebVIew添加多个cookie

遍历添加多个cookie 后台收到的cookie是都好隔开的,用他们的方法获取不到我这边设置的cookie,于是尝试自己拼接分号,后台可以拿到


   _urlString=  [_urlString dm_UTF8String];

    NSURL *url = [NSURL URLWithString:_urlString];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];

    request.HTTPShouldHandleCookies = YES;

    NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies];

    DMLog(@"==cookies=====%@",cookies);

    NSMutableArray *cookieStrs = [NSMutableArray array];

    for(NSHTTPCookie*coincookies) {

        NSString*cookieStr = [NSStringstringWithFormat:@"%@=%@",co.name,co.value];

        [cookieStrsaddObject:cookieStr];

    }

    NSString*cookieStr = [cookieStrscomponentsJoinedByString:@";"];

    [requestaddValue:cookieStrforHTTPHeaderField:@"Cookie"];

    [self.webView loadRequest:request];

你可能感兴趣的:(WKWebVIew添加多个cookie)