2

In my app, I want to do login using WKWebView and then all further request to server is done.

I'm able to perform successful login using WKWebView. On it's success I get session information. I had implemented it previously using UIWebView and it was working properly. All my further web service call were working fine in UIWebView.

Now when I implemented login with WKWebView it is successfully login but when i hit different link (URL) it gives me logout response every time and I'm trying to call service using Cookies and , it's not giving me proper response as session information are not being passed.

Is there any way, I can store those session information of WKWebView

Any help will be appreciated. Please help!

Here is the code where i m set cookies : -

*{
    // Set iPad cookie for our requests
    NSString*               dotDomain = [NSString stringWithFormat:@".%@", CookieDomain];
    NSDictionary*       newCookieDict = [NSMutableDictionary
                                         dictionaryWithObjectsAndKeys:
                                         dotDomain, NSHTTPCookieDomain,
                                         @"iPad", NSHTTPCookieName,
                                         @"/", NSHTTPCookiePath,
                                         @"1", NSHTTPCookieValue,
                                         @"2040-1-1 00:00:00 -0700", NSHTTPCookieExpires,
                                         nil];
    NSHTTPCookie*       newCookie = [NSHTTPCookie cookieWithProperties:newCookieDict];
    [[NSHTTPCookieStorage sharedHTTPCookieStorage] setCookie:newCookie];
}

// Don't block cookies, so dosespot will work
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];*

Here is my Request HTTP Header and Response HTTP Header :-

*Request HTTP Header : {
"Accept-Encoding" = gzip;
Cookie = "cookie_test=1; cookie_test=1; CAKEPHP=jkn36knqoul2f14rebb8k5h882; iPad=1";
"User-Agent" = "iPad App";

}*

**Response HTTP Header : {
Connection = "Keep-Alive";
"Content-Encoding" = gzip;
"Content-Length" = 5668;
"Content-Type" = "text/html";
Date = "Tue, 10 May 2016 13:58:14 GMT";
"Keep-Alive" = "timeout=5, max=99";
Server = "Apache/2.2.22 (Ubuntu)";
Vary = "Accept-Encoding";
"X-Powered-By" = "PHP/5.3.10-1ubuntu3.15";

}**

Raza Khan
  • 21
  • 5

0 Answers0