Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 07-13-2009, 12:48 PM   #1 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 9
dholowiski is on a distinguished road
Default Restarting UIWebView?

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];
dholowiski is offline   Reply With Quote
Old 07-13-2009, 05:13 PM   #2 (permalink)
Registered Member
 
Join Date: Jul 2009
Posts: 9
dholowiski is on a distinguished road
Default Fixed

Well I figured it out. It turns out if you use -1 the cookie expires immediatley instead of on the next launch. I figured this out just by messing around.
Much easier than trying to restart the browser or the app programatically!
Code:
http://en.wikipedia.org/w/mobileRedirect.php?to=http://en.wikipedia.org/wiki/Main_Page&expires_in_days=-1
dholowiski is offline   Reply With Quote
Reply

Bookmarks

Tags
cookies, delete, uiwebview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 316
9 members and 307 guests
chiataytuday, coolman, givensur, ipodphone, jbro, mottdog, mtl_tech_guy, Punkjumper, vilisei
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,649
Threads: 94,114
Posts: 402,882
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Anwerbl
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 09:18 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0