iOS WebView添加自定义cookie

NSDictionary *properties = [[NSMutableDictionary alloc] init];
        [properties setValue:Member_Id forKey:NSHTTPCookieValue];
        [properties setValue:@"memberId" forKey:NSHTTPCookieName];
        [properties setValue:[[NSURL URLWithString:_info] host] forKey:NSHTTPCookieDomain];
        [properties setValue:[[NSURL URLWithString:_info] path] forKey:NSHTTPCookiePath];
        [properties setValue:[NSDate dateWithTimeIntervalSinceNow:60*60] forKey:NSHTTPCookieExpires];
        NSHTTPCookie *cookie = [[NSHTTPCookie alloc] initWithProperties:properties];
        [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:cookie];
[_scanDetailWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:_info]]];

你可能感兴趣的:(iOS WebView添加自定义cookie)