Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用cookie问题 #4

Closed
xyy112121 opened this issue Dec 5, 2019 · 2 comments
Closed

使用cookie问题 #4

xyy112121 opened this issue Dec 5, 2019 · 2 comments

Comments

@xyy112121
Copy link

我使用的时候是否是第一次设置了cookie,之后的请求就不需要管了?因为我目前就是这样操作了,但是后续也不行,我设置的cookie如下:
#pragma mark - 请求

  • (void)loadRequest {
    if (!self.url) {
    return;
    }

    NSString *cookie = @"JSESSIONID=2E17260F9C95A42F654C1BC6E6BD215B; Path=/oa; HttpOnly; SHAREJSESSIONID=61efdf3a-4c1b-4eba-90b5-551c4e295c95; Path=/oa; HttpOnly; rememberMe=deleteMe; Path=/oa; Max-Age=0; Expires=Wed; 04-Dec-2019 08:24:38 GMT";
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:self.url]];
    [request setValue:cookie forHTTPHeaderField:@"Cookie"];
    [self.webView loadRequest:request];
    }
    在这人页面上有附件下载,点击,感觉这个cookie设置没有效果

@karosLi
Copy link
Owner

karosLi commented Dec 5, 2019

首次请求设置cookie是一个同步请求,这样是用于打开页面时才用得到,你的这个附件下载,是一个ajax请求,那这个ajax请求也是需要处理cookie问题的;后学的还有请求响应头,302重定向等问题,也是需要处理 cookie 问题的,你可以看下我写的博客,或者看下源码。

@karosLi karosLi closed this as completed Dec 12, 2019
@karosLi
Copy link
Owner

karosLi commented Dec 12, 2019

我先关闭了哈

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants