Note that there are some explanatory texts on larger screens.

plurals
  1. POUIWebview does not get cookies
    primarykey
    data
    text
    <p>My UIWebview is not saving cookies at all. It is stuck in cookieless mode and as a result, the webpage is putting the cookie information in the url instead.</p> <p>Here is what I am doing. I have a singleton for my UIWebview and 4 UITabBar buttons on the bottom. Each tabbar button takes the user to a different page on the site. Now, when the user is navigating the site through the webview itself, everything is fine and session persists. But the second a user clicks on a tabbar button, the session gets reset.</p> <p>I even set NSHttpCookieStorage to always accept cookies. Still no go.</p> <p>Here is the code for my singleton for UIWebview and NSMutableUrlRequest</p> <pre><code> public static UIWebView instance; public static NSMutableUrlRequest urlRequest; public static NSUrlConnection connection; public static NSHttpCookieStorage cookie; static bool TokenSent = false; public UIWebViewSingleton () {} public static UIWebView Instance { get { if (instance == null) { Debugger.Debug ("new uiwebview created"); cookie = NSHttpCookieStorage.SharedStorage; cookie.AcceptPolicy = NSHttpCookieAcceptPolicy.Always; connection = new NSUrlConnection(); instance = new UIWebView(new RectangleF(0f, 0f, 320f, 416f)); instance.ScalesPageToFit = true; instance.LoadStarted += delegate { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; }; instance.LoadFinished += delegate { UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; AcquireUserId(); }; instance.MultipleTouchEnabled = false; } return instance; } } public static NSMutableUrlRequest UrlRequest { get { if (urlRequest == null) { urlRequest = new NSMutableUrlRequest(); } return urlRequest; } } </code></pre> <p>This is how I change to a page based on which button was pressed. The back button is working fine.</p> <pre><code> case BTN_BACK: btn_ret.TouchUpInside += delegate(object sender, EventArgs e) { UIWebViewSingleton.Instance.GoBack(); }; break; case BTN_GUIDE: btn_ret.TouchUpInside += delegate(object sender, EventArgs e) { UIWebViewSingleton.UrlRequest.Url = new NSUrl(StaticFileNames.GuideUrl); UIWebViewSingleton.Instance.LoadRequest (UIWebViewSingleton.UrlRequest); }; break; case BTN_HOME: btn_ret.TouchUpInside += delegate(object sender, EventArgs e) { UIWebViewSingleton.UrlRequest.Url = new NSUrl(StaticFileNames.BaseUrl); UIWebViewSingleton.Instance.LoadRequest (UIWebViewSingleton.UrlRequest); }; break; </code></pre> <p>Does anyone have any ideas as to why my UIWebView is not accepting cookies? I'm still confused about NSHttpCookieStorage and if I'm using that correctly.</p> <p>Thanks a lot.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload