First, yes I did search for this question... couldn't find anything.
I have a UIWebView that connects to Wikipedia. Wikipedia now redirects safari to m.wikipedia.org, which is kind of buggy.
I plan to let my users decide wether they access the mobile site or the standard site by setting a cooke.
I'm setting the cookie by requesting the following url:
Code:
http://en.wikipedia.org/w/mobileRedirect.php?to=http://en.wikipedia.org/wiki/Main_Page&expires_in_days=30
That works fine. But I want them to be able to switch back to getting the mobile site. The best I could figure was requesting the following:
Code:
http://en.wikipedia.org/w/mobileRedirect.php?to=http://en.wikipedia.org/wiki/Main_Page&expires_in_days=0
which makes it a session cookie, but then the user has to restart the appilcation for this to take effect.
So I have several questions: First, how can I (and should I) re-launch UIWebView so that the session cookie expires?
Second, should I delete the cookie instead? I tried the code below, but it didn't delete anything.
NSEnumerator* enumerator;
NSHTTPCookie* cookie;
enumerator = [[jar cookies] objectEnumerator];
NSLog(@"Deleting all cookies from the jar.");
while (cookie = [enumerator nextObject]) {
[jar deleteCookie:cookie];
}
[enumerator release];
[cookie release];