所以我有一个可以访问我的 webview 的 phonegap 应用程序,基本上就像
window.load("URLTOMYAPPGOESHERE");
在 webview 中,一旦人们登录,我就会保存用户 ID 的 cookie。当应用程序加载时,如果 userid cookie 已经存在,它将显示帐户详细信息。
今天早上,当我打开应用程序时,cookie 是另一个用户的 ID!javascript cookie 是否有可能保存到 webview/url 或应用程序(认为 webview 是本地的),当其他人从他们的手机访问该 webview 时,他们会得到与另一个用户最后设置的相同的 cookie ? 我认为 JS cookie 是设备本地的,但这是我能想到的唯一原因。这就是我设置cookie的方式。
function setCookie(cname, cvalue, exdays) {
var d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}