Android and Iphone: Enable cookies for local html files

2,729 views
Skip to first unread message

Colleen Liley

unread,
May 8, 2012, 2:25:30 PM5/8/12
to phonegap
I have an app where I'm using Childbrowser to show local HTML lessons.
These lessons rely heavily on cookie set variables. The cookies work
fine in Iphone 5+ but not 4.3 and lower. The cookies don't work on my
Galaxy
Tab (3.1) I'm testing on but do on a 2.2 and 2.3 cell phone. I tried a
wildcard whitelist but that didn't help.
I'm getting the same issue in PG 1.3 and associated CB plugin as well
as Cordova 1.7 and associated CB plugin.

Any ideas?

Alain Renaud

unread,
May 31, 2012, 4:41:06 PM5/31/12
to phon...@googlegroups.com
I seem to have almost the same problem (although we do NOT use ChildBrowser but
our own client cookies, no server cookies here). What I can tell you is that
cookies DO work for us when run in a pure browser environment, including on an
iPhone 4.1 They also DO work flawlessly on Android 2.3.4 both in a pure browse
AND PhoneGap 1.6.1 environments. BUT they do NOT work in PhoneGap on that iPhone
so far for us. So I'm asking you if (apart from modifying native code which is
not an option for us as we are multi-platforms) you got around that problem.
Thanks in advance for any tips, A.R.


Alain Renaud

unread,
Jun 1, 2012, 2:10:29 PM6/1/12
to phon...@googlegroups.com
Well thanks for the answer :-)
Anyways, FYI it turns out this problem is no more on iOS 5.1+ (or even 5.0?) so
the solution is to enforce that OS version; apparently even iPhone 3 owners can
upgrade to 5.1 so it's a no-brainer. A.R.


Hemul Hemulsky

unread,
Jun 2, 2012, 6:07:51 AM6/2/12
to phon...@googlegroups.com
You need to enable cookies in cordova WebView from native code. On ios try to modify ViewController.m in xcode project. Find webViewDidLoad method and add lines:
NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];

2012/6/2 Alain Renaud <renaud...@hotmail.com>


--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en

For more info on PhoneGap or to download the code go to www.phonegap.com

Reply all
Reply to author
Forward
0 new messages