Can't write cookie on Tablet running Android 3.1?
Not sure if anyone can help me on this; but let me throw it out there. I'm really not sure if this is a Phonegap issue, a device issue or an Android SDK version. Tell me what you think..
I have an Android Applet using phonegap version 0.9.5; Android SDK 3.0. One of the features is after login; I write a cookie using javascript on the device to store the email entered. This works in many of the phones I have tested on and also tested on all the emulators.
The problem is I have an Acer A500 tablet running version 3.1. Every time I login; I can not write the cookie to the tablet. It appears that I get the length of the cookie; always 0. But can't write a cookie or read a cookie
So; any ideas if this is a Phonegap issue, a Acer table issue or a Android sdk issue? Suggestions?
The javascript to write/read the cookie is pretty standard:
----Write Cookie--- var exdate = new Date(); exdate.setDate(exdate.getDate() + 1095);
document.cookie = "email=" + escape(oForm.elements['email'].value) +
";expires=" + exdate.toUTCString();
--Read Cookie---- function readCookie(cookieName) { var cookieValue = null;
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(cookieName + "=");
if (c_start!=-1)
{
c_start=c_start + cookieName.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
r开发者_高级运维eturn unescape(document.cookie.substring(c_start,c_end));
}
}
return cookieValue;
}
When I read the cookie..email always returns null and the length of the cookie is 0.
Thanks for any advice or suggestions... Tony
It's a bug with Android 3.1. I tested the exact same code with 2.3.4 (sdk version 10) and it works as expected. The 3.1 was on a Galaxy Tab and the 2.3.4 was on a Nexus S.
精彩评论