I am using UIWebView in my application. I want to upload the url to the first webview, and this user can log in to his account. After logging in, the user logged out of the web view and performed other actions in iOS native views. Later, when he calls the same URL, he must log in. How is this possible? I saw this in Gmail, when I logged into my account on one tab and closed it, my GMAIl account is registered in safari whenever I open any tab.
I tried something below but didn't work. Please offer me a solution
-(void)loadCookies { NSArray *cookies = [NSKeyedUnarchiver unarchiveObjectWithData: [[NSUserDefaults standardUserDefaults] objectForKey: @"cookies"]]; NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; for (NSHTTPCookie *cookie in cookies) { [cookieStorage setCookie: cookie]; } } -(void)saveCookies { NSData *cookiesData = [NSKeyedArchiver archivedDataWithRootObject: [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies]]; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject: cookiesData forKey: @"cookies"]; [defaults synchronize]; }
My application stream as below.
1. Build a URL in UIWebview - http://www.userlogin.com 2. Application from this controller 3. Other features of the application. 4.Calling the same URL in another UIWebView - http://www.userlogin.com
Here I need to show my session.
source share