开发者

UIWebView not accepting cookies

I've got an iPad app with a UIWebView in it, and need it to accept cookies via calls from JavaScript. It seems to not accept new cookies, even after explicitly setting the 'cookieAcceptPolicy' of NSHTTPCookieStorage to 'always'.

I saw one other unanswered question on this suggesting the problem might be related to iOS开发者_StackOverflow社区 4.2: http://groups.google.com/group/phonegap/browse_thread/thread/81bc91bdbfe7bf7b

Can anyone confirm that UIWebView accepts cookies >= iOS 4.2.1?

Also, here is the javascript that tries to set the cookie:

function setCookie(c_name,value,exdays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value=escape(value) + ((exdays==null) ? "" : "; expires="+exdate.toUTCString());
    document.cookie=c_name + "=" + c_value;
}

Called by:

setCookie("ReferrerValue",document.URL,365);

I guess if this can't work I'll need a way to do it Objective-C but that is a whole other question. Thank you.


Do you have control over the web page being called via the web view?

If so, then you should have the ability to use libraries like lawnchair or jStorage for simple client side persistant storage.

If not and probably a good idea in any case is to take a look at the specific iOS code in Callback AKA PhoneGap. This problem has been solved, its just a matter of finding where exactly it is. HTH

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜