views:

484

answers:

2

So I have a web page inside my bundle, which I load in a UIWebView. However, the page doesn't seem to be able to store any cookies, even though other (online) websites can. How do I get it to store my cookies?

A: 

I don't think you can. Cookies are connected to a specific site and path. That does not map well to documents served from disk.

I don't really see a simple fix for this. One thing you could try is to embed a little web server in your app and then use it to serve that content on localhost.

St3fan
Dear dear...well thanks for the quick response.
tmoc
A: 

You can. I load an html file from my bundle and it saves cookies fine and I reload those cookies next time it starts up no problems. They are in the CookieStorage. If you dump out all the cookies in there for your app you should find any cookies your application saved.

even if you have trouble getting your webapp to save the cookies you could always explicitly retrieve the cookies via javascript and in obj-c code save the returned data into cookiestorage. Some tips on using cookiestorage...http://blog.andrewpaulsimmons.com/2008/08/add-set-and-delete-cookies-in-uiwebview.html

casey